4 Backing up and Restoring Private Automation Hub
The following chapter provides information about backing up and restoring Private Automation Hub. Perform an offline backup where all relevant services are stopped and the data is not changing at the time of the backup; this backup is consistent by definition.
Offline Backing up Private Automation Hub
- Create a backup directories. Ensure you have sufficient disk space and consider making
the directory persistent.
Note:
For the purposes of this document, we use a folder in the home directory, which is not secure.sudo mkdir -p ~/backup/etc/pulp ~/backup/var/lib/pulp ~/backup/etc/nginx/pulp ~/backup/var/lib/pgsql/data
- Stop the following services in the following
order:
sudo systemctl stop pulpcore sudo systemctl stop nginx sudo systemctl stop postgresql
- Copy the following folders into the backup directory.
Note:
cp option r ensures that the backup includes all subdirectories and p ensures that all permissions are preserved.sudo cp -rp /etc/pulp/ ~/backup/etc/ sudo cp -rp /var/lib/pulp ~/backup/var/lib/ sudo cp -rp /etc/nginx/pulp ~/backup/etc/nginx/ sudo cp -rp /var/lib/pgsql/data ~/backup/var/lib/pgsql/
- Restart the services in the following
order:
sudo systemctl start postgresql sudo systemctl start pulpcore* --all sudo systemctl start nginx
Note:
Consider testing the backup to ensure it works as expected. For more information, see Offline Restoring Private Automation Hub.
Offline Backing up Private Automation Hub with a Remote Database
- On the Private Automation Hub server, create a backup directories. Ensure you have
sufficient disk space and consider making the directory persistent.
Note:
For the purposes of this document, we use a folder in the home directory, which is not secure.sudo mkdir -p ~/backup/etc/pulp ~/backup/var/lib/pulp ~/backup/etc/nginx/pulp
- On the database server, create a backup directory for the following folder. Ensure you have
sufficient disk space and consider making the directory persistent.
sudo mkdir -p ~/backup/var/lib/pgsql/data
- Stop the following services on the Private Automation Hub server in the following
order:
sudo systemctl stop pulpcore sudo systemctl stop nginx
- Stop the following service on the database
server:
sudo systemctl stop postgresql
- Copy the following folders into the backup directory from the Private Automation Hub server.
Note:
cp option r ensures that the backup includes all subdirectories and p ensures that all permissions are preserved.sudo cp -rp /etc/pulp/ ~/backup/etc/ sudo cp -rp /var/lib/pulp ~/backup/var/lib/ sudo cp -rp /etc/nginx/pulp ~/backup/etc/nginx/
- Copy the following folders into the backup directory from the database server.
sudo cp -rp /var/lib/pgsql/data ~/backup/var/lib/pgsql/
- Restart the services on the database
Server:
sudo systemctl start postgresql
- Restart the services on Private Automation Hub in the following
order:
sudo systemctl start pulpcore* --all sudo systemctl start nginx
Note:
Consider testing the backup to ensure it works as expected. For more information, see Offline Restoring Private Automation Hub.
Offline Restoring Private Automation Hub
Note:
All data entered after taking an offline backup is lost when the backup is restored.- If running, stop the following services in the following
order:
sudo systemctl stop pulpcore sudo systemctl stop nginx sudo systemctl stop postgresql
- Copy the following folders from the backup directory to the Private Automation Hub
server.
Note:
cp option r ensures that the backup includes all subdirectories and p ensures that all permissions are preserved.sudo cp -rp ~/backup/etc/pulp /etc/ sudo cp -rp ~/backup/var/lib/pulp /var/lib/ sudo cp -rp ~/backup/etc/nginx/pulp /etc/nginx/ sudo cp -rp ~/backup/var/lib/pgsql/data /var/lib/pgsql/
- Restart the services in the following
order:
sudo systemctl daemon-reload sudo systemctl start postgresql sudo systemctl start pulpcore* --all sudo systemctl start nginx
Offline Restoring Private Automation Hub with a Remote Database
Note:
All data entered after taking an offline backup is lost when the backup is restored.- Stop the following services on the Private Automation Hub server in the following
order:
sudo systemctl stop pulpcore sudo systemctl stop nginx
- Stop the following service on the database
server:
sudo systemctl stop postgresql
- Copy the following folders from the backup directory to the Private Automation Hub
server.
Note:
cp option r ensures that the backup includes all subdirectories and p ensures that all permissions are preserved.sudo cp -rp ~/backup/etc/pulp /etc/ sudo cp -rp ~/backup/var/lib/pulp /var/lib/ sudo cp -rp ~/backup/etc/nginx/pulp /etc/nginx/
- Copy the following folders from the backup directory to the database Server.
sudo cp -rp ~/backup/var/lib/pgsql/data /var/lib/pgsql/
- Restart the services on the database
Server:
sudo systemctl daemon-reload sudo systemctl start postgresql
- Restart the services on Private Automation Hub in the following
order:
sudo systemctl daemon-reload sudo systemctl start pulpcore* --all sudo systemctl start nginx
Offline Restoring Private Automation Hub to a New Host
Note:
All data entered after taking an offline backup is lost when the backup is restored.- Ensure the new host is installed with exactly the same configuration and settings as the original host where the backup was taken. This includes running identical installer playbooks and the software versions (for example, same database version and Private Automation Hub version). The host and IP address are the only parameters that need to change when running the playbook. For more information, see Installing Private Automation Hub.
- If running, stop the following services on the original host in the following
order:
sudo systemctl stop pulpcore sudo systemctl stop nginx sudo systemctl stop postgresql
- Copy the following folders from the backup directory to the new Private Automation Hub server
using whatever method you need. Copy the backup files to the following directories:
Note:
cp option r ensures that the backup includes all subdirectories and p ensures that all permissions are preserved.sudo cp -rp ~/backup/etc/pulp /etc/ sudo cp -rp ~/backup/var/lib/pulp /var/lib/ sudo cp -rp ~/backup/etc/nginx/pulp /etc/nginx/ sudo cp -rp ~/backup/var/lib/pgsql/data /var/lib/pgsql/
- Update the /etc/pulp/settings.local.py on the new host with the following paramters:
DATABASES = {'default': {'HOST': '<IP address or host name>', 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'pulp', 'USER': 'pulp', 'PASSWORD': '<db_password>'}} TOKEN_SERVER = 'https://<<IP address or host name>>/token/' and CONTENT_ORIGIN = 'https://<IP address or host name>'
In the previous example, <IP address or host name> is the IP address or host name of the standalone Private Automation Hub server and <db_password> is the password for the database.
- Restart the services in the following
order:
sudo systemctl daemon-reload sudo systemctl start postgresql sudo systemctl start pulpcore* --all sudo systemctl start nginx
Offline Restoring Private Automation Hub to a New Host with Remote Database
Note:
All data entered after taking an offline backup is lost when the backup is restored.- Ensure the new host is installed with exactly the same configuration and settings as the original host and remote database where the backup was taken. This includes running identical installer playbooks and the software versions (for example, same database version and Private Automation Hub version). The host and IP address are the only parameters that need to change when running the playbook. For more information, see Installing Private Automation Hub.
- If running, stop the following services on the Private Automation Hub server in the following
order:
sudo systemctl stop pulpcore sudo systemctl stop nginx
- If running, stop the following service on the database
server:
sudo systemctl stop postgresql
- Copy the following folders from the backup directory to the new Private Automation Hub server
using whatever method you need. Copy the backup files to the following directories:
Note:
cp option r ensures that the backup includes all subdirectories and p ensures that all permissions are preserved.sudo cp -rp ~/backup/etc/pulp /etc/ sudo cp -rp ~/backup/var/lib/pulp /var/lib/ sudo cp -rp ~/backup/etc/nginx/pulp /etc/nginx/
- Update the
/etc/pulp/settings.local.py
on the new Private Automation Hub server with the following paramters:DATABASES = {'default': {'HOST': '<database IP address or host name>', 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'pulp', 'USER': 'pulp', 'PASSWORD': '<db_password>'}} TOKEN_SERVER = 'https://<<IP address or host name>>/token/' and CONTENT_ORIGIN = 'https://<IP address or host name>'
In the previous example, <database IP address or host name> is the IP address or host name of the database, <IP address or host name> is the IP address or host name of the standalone Private Automation Hub server and <db_password> is the password for the database.
- Copy the following folders from the backup directory to the new database server using
whatever method you need. Copy the backup files to the following
directory:
sudo cp -rp ~/backup/var/lib/pgsql/data /var/lib/pgsql/
- Restart the services on the database
Server:
sudo systemctl daemon-reload sudo systemctl start postgresql
- Restart the services on Private Automation Hub in the following
order:
sudo systemctl daemon-reload sudo systemctl start pulpcore* --all sudo systemctl start nginx