Freezer-backup-restore

= Backup =

Using freezer agent
freezer-agent --action backup --mode mysql --path-to-backup /var/lib/mysql/ --mysql_conf /etc/mysql/debian.cnf --snapshot --max-priority --container freezer_backup_devstack --storage swift

Using the python-freezerclient or scheduler
This would generate a job that will be executed by the scheduler

Create a job
Create a backup job in /tmp/job_backup.conf:

{        "job_actions": [{ "freezer_action": { "action": "backup", "mode": "mysql", "mysql_conf": "/etc/mysql/debian.cnf", "path_to_backup": "/var/lib/mysql/", "backup_name": "freezer-db-mysql", "snapshot": true, "container": "freezer_backup_devstack_1_alwayslevel", "storage": "swift" },                 "max_retries": 5, "max_retries_interval": 60, "mandatory": true }],        "job_schedule": {}, "description": "mysql backup" }

Save the job
freezer-scheduler job-create -c client_node_1 --file /tmp/job_backup.conf freezer job-create -C client_node_1 --file /tmp/job_backup.conf
 * for kilo, liberty and mitaka:
 * newton onwards:

Start the job
freezer-scheduler job-start -j job_id freezer job-start job_id
 * for kilo, liberty and mitaka:
 * newton onwards:

Using freezer agent
freezer-agent --action backup --mode fs --path-to-backup /home/vagrant/important_dir --container /home/remote_machine/storage --backup-name ssh_backup --storage ssh --ssh-username ubuntu --ssh-key ~/.ssh/id_rsa --ssh-host 8.8.8.8

Using the python-freezerclient or scheduler
This would generate a job that will be executed by the scheduler

Create a backup job in /tmp/job_backup.conf:

{        "job_actions": [{ "freezer_action": { "action": "backup", "mode": "fs", "path_to_backup": "/home/vagrant/important_dir/", "backup_name": "ssh_backup", "container": "freezer_backup_devstack_1_alwayslevel", "storage": "ssh", "ssh_username": "ubuntu", "ssh_key": "~/.ssh/id_rsa", "ssh_host": "8.8.8.8" },                "max_retries": 5, "max_retries_interval": 60, "mandatory": true }],        "job_schedule": {}, "description": "ssh backup" }

Save the job
freezer-scheduler job-create -c client_node_1 --file /tmp/job_backup.conf freezer job-create -C client_node_1 --file /tmp/job_backup.conf
 * for kilo, liberty and mitaka:
 * newton onwards:

Start the job
freezer-scheduler job-start -j job_id freezer job-start job_id
 * for kilo, liberty and mitaka:
 * newton onwards:

Nova Backups
If our data is stored on a nova instance disk, we can implement file backup using nova snapshots or volume backups.

If you provide nova arguments in the parameters, freezer assumes that all necessary data is located on instance disk and it can be successfully stored using nova snapshot mechanism.

For example if we want to store our MySQL located on instance disk, we will execute the same actions as in the case of lvm or tar snapshots, but we will invoke nova snapshot instead of lvm or tar.

After that we will place the snapshot in a Swift container as a dynamic large object.

container// <- large object with metadata container_segments// /segments...

Restore will create a snapshot from stored data and restore an instance from this snapshot. Instance will have different id and old instance should be terminated manually.

Execute a nova backup:

freezer-agent --mode nova --nova-inst-id 3ad7a62f-217a-48cd-a861-43ec0a04a78b

Execute a MySQL backup with Nova:

freezer-agent --mysql-conf /root/.freezer/freezer-mysql.conf --container freezer_mysql-backup-prod --mode mysql --backup-name mysql-ops002 --nova-inst-id 3ad7a62f-217a-48cd-a861-43ec0a04a78b

Cinder Backups
Cinder has its own mechanism for backups, and freezer supports it. But it also allows creating a glance image from volume and uploading to swift.

To make a cinder backup you should provide cinder-vol-id or cindernative-vol-id parameters in command line arguments. Freezer doesn’t do any additional checks and assumes that making a backup of that image will be sufficient to restore your data in the future.

Execute a cinder backup:

freezer-agent --mode cinder --cinder-vol-id 3ad7a62f-217a-48cd-a861-43ec0a04a78b

Execute a MySQL backup with Cinder:

freezer-agent --mysql-conf /root/.freezer/freezer-mysql.conf --container freezer_mysql-backup-prod --mode mysql --backup-name mysql-ops002 --cinder-vol-id 3ad7a62f-217a-48cd-a861-43ec0a04a78b

Parallel Backups
Parallel backup can be executed only by config file. In config file you should create n additional sections that start with “storage:”

Example [storage:my_storage1], [storage:ssh], [storage:storage3]

Each storage section should have ‘container’ argument and all parameters related to the storage

Example: ssh-username, ssh-port

For swift storage you should provide additional parameter called ‘osrc’ Osrc should be a path to file with Openstack Credentials like:

unset OS_DOMAIN_NAME export OS_AUTH_URL=http://url:5000/v3 export OS_PROJECT_NAME=project_name export OS_USERNAME=username export OS_PASSWORD=secret_password export OS_PROJECT_DOMAIN_NAME=Default export OS_USER_DOMAIN_NAME=Default export OS_IDENTITY_API_VERSION=3 export OS_AUTH_VERSION=3 export OS_CACERT=/etc/ssl/certs/ca-certificates.crt export OS_ENDPOINT_TYPE=internalURL

for Windows replace export with set

Example of Config file for two local storages and one swift storage:

[default] action = backup mode = fs   path_to_backup = /foo/ backup_name = mytest6 always_level = 2 max_segment_size = 67108864 container = /tmp/backup/ storage = local [storage:first] storage=local container = /tmp/backup1/ [storage:second] storage=local container = /tmp/backup2/ [storage:swift] storage=swift container = test osrc = openrc.osrc

MongoDB Backup
We assume our mongo volume is “/dev/mongo/mongolv” and the volume group is “mongo”:

sudo freezer-agent --lvm-srcvol /dev/mongo/mongolv --lvm-dirmount /var/lib/snapshot-backup --lvm-volgroup mongo --path-to-backup /var/lib/snapshot-backup/mongod_ops2 --container freezer_mongodb-backup-prod --exclude "*.lock" --mode mongo --backup-name mongod-ops2

= Restore =

MySQL
Execute a MySQL restore of the backup name holly-mysql. Let’s stop mysql service first:

sudo service mysql stop

Using freezer agent
sudo freezer-agent --action restore --container freezer_foobar-container-2 --backup-name mysq-prod --hostname db-HP-DL380-host-001 --restore-abs-path /var/lib/mysql --restore-from-date "2014-05-23T23:23:23"

Using the python-freezerclient or scheduler
Create a restore file in /tmp/job_restore.conf:

{        "job_actions": [{ "freezer_action": { "action": "restore", "restore_abs_path": "/var/lib/mysql", "restore_from_host": "test_machine_1", "backup_name": "freezer-db-mysql", "container": "freezer_backup_devstack_1" },                 "max_retries": 5, "max_retries_interval": 60, "mandatory": true }],        "description": "mysql test restore" }

Save the job
freezer-scheduler job-create -c client_node_1 --file /tmp/job_backup.conf freezer job-create -C client_node_1 --file /tmp/job_backup.conf
 * for kilo, liberty and mitaka:
 * newton onwards:

Start the job
freezer-scheduler job-start -j job_id freezer job-start job_id
 * for kilo, liberty and mitaka:
 * newton onwards:

And finally restart mysql:

sudo service mysql start

Restore of a MongoDB backup
sudo freezer-agent --action restore --container freezer_foobar-container-2 --backup-name mongobigdata --hostname db-HP-DL380-host-001 --restore-abs-path /var/lib/mongo --restore-from-date "2014-05-23T23:23:23

Restore a filesystem backup
freezer-agent --action restore --mode fs --backup-name ssh_backup --container f/home/remote_machine/storage --restore_abs_path /home/vagrant/important_dir --restore_from_host test_machine_1 --storage ssh --ssh-username ubuntu --ssh-key ~/.ssh/id_rsa --ssh-host 8.8.8.8

Restore Nova backup
freezer-agent --action restore --nova-inst-id 3ad7a62f-217a-48cd-a861-43ec0a04a78b --restore-from-date "2016-08-01T23:23:23

Restore Cinder backup
freezer-agent --action restore --cinder-vol-id 3ad7a62f-217a-48cd-a861-43ec0a04a78b --restore-from-date "2016-08-01T23:23:23