Difference between revisions of "Freezer-backup-restore"
Memo Garcia (talk | contribs) (Created page with "= Backup = == MySQL == 1: Using freezer agent: freezer-agent --action backup --mode mysql --path-to-backup /var/lib/mysql/ --mysql_conf /etc/mysql/debian.cnf --snapshot...") |
Memo Garcia (talk | contribs) |
||
Line 3: | Line 3: | ||
== MySQL == | == MySQL == | ||
− | + | ==== 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 | 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 | This would generate a job that will be executed by the scheduler | ||
Line 46: | Line 46: | ||
* newton onwards: | * newton onwards: | ||
freezer job-start job_id | freezer job-start job_id | ||
+ | |||
+ | |||
+ | == Backup to SSH destination == | ||
+ | |||
+ | ==== 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 === | ||
+ | |||
+ | * for kilo, liberty and mitaka: | ||
+ | freezer-scheduler job-create -c client_node_1 --file /tmp/job_backup.conf | ||
+ | * newton onwards: | ||
+ | freezer job-create -C client_node_1 --file /tmp/job_backup.conf | ||
+ | |||
+ | === Start the job === | ||
+ | * for kilo, liberty and mitaka: | ||
+ | freezer-scheduler job-start -j job_id | ||
+ | * newton onwards: | ||
+ | freezer job-start job_id | ||
+ | |||
+ | == 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/<instance_id>/<timestamp> <- large object with metadata container_segments/<instance_id>/<timestamp>/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 --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 --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 |
Revision as of 11:23, 27 June 2016
Contents
Backup
MySQL
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
- for kilo, liberty and mitaka:
freezer-scheduler job-create -c client_node_1 --file /tmp/job_backup.conf
- newton onwards:
freezer job-create -C client_node_1 --file /tmp/job_backup.conf
Start the job
- for kilo, liberty and mitaka:
freezer-scheduler job-start -j job_id
- newton onwards:
freezer job-start job_id
Backup to SSH destination
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
- for kilo, liberty and mitaka:
freezer-scheduler job-create -c client_node_1 --file /tmp/job_backup.conf
- newton onwards:
freezer job-create -C client_node_1 --file /tmp/job_backup.conf
Start the job
- for kilo, liberty and mitaka:
freezer-scheduler job-start -j job_id
- newton onwards:
freezer job-start job_id
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/<instance_id>/<timestamp> <- large object with metadata container_segments/<instance_id>/<timestamp>/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 --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 --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