FileCloud Backup and Restore - Linux Tool

Note: This utility is deprecated and will be removed in future releases.

Starting with FileCloud 11.0, an easy to use FileCloud Server Backup and Restore option is available for administrators.

See FileCloud Server Backup for more details

FileCloud is bundled with necessary tool to perform full backups of your cloud installation ie., both files and database.

Some of the features of these backup scripts:

  • can be run at anytime manually from command line
  • can be part of an automated system like cron job.
  • can be run on a live cloud installation (though its safer to do backup of cloud in maintenance mode).
  • can backup to local or remote linux targets.


In this section you can learn some basic tasks such as

  1. Initializing backup system
  2. Adding a new host to the backup system
  3. Removing a target
  4. Creating new backups
  5. Removing existing backups
  6. Listing existing backups
  7. Restoring a backup

Terminologies

Here are some basic terminologies used to explain the backup tool.

Backup Target: Host where the backups are stored.

Backup Directory: Directory under which the backups are stored.

Initializing Backup Tool

Backup tool has to be initialized before it can be used to backup your cloud installation. This initialization needs to be done only once and tool will automatically initialize itself upon first use. During this initialization process, the tool performs an important routine that the user needs to be aware of.

SSH Key Generation : The tool generates a RSA ssh key pair during initialization. This key pair will be used to communicate between the tool and backup targets. This enables tool to communicate with the backup target without prompting for password every time. These are encrypted keys and are safer than entering passwords everytime for communication. Also the tool exchanges the key with the localhost and will be used to run even commands on the local host.

When the backup tool is run without any options, it initializes the tool on first run and then displays help. Further runs only displays help. Following section shows a session initializing the backup tool.

Initializing backup tool
madhan@li111-150:~$ cd /var/www/resources/backup
madhan@li111-150:/var/www/resources/backup$ sudo chmod +x backup.sh
madhan@li111-150:/var/www/resources/backup$ sudo ./backup.sh
Feb 18 01:26:05 : Initializing backup system
Feb 18 01:26:05 : Generating ssh encryption keys
Generating public/private rsa key pair.
Your identification has been saved in ./keys/id_rsa.
Your public key has been saved in ./keys/id_rsa.pub.
The key fingerprint is:
f4:cd:e8:ff:1e:db:e6:b4:7f:f7:da:d4:02:16:dd:ba root@li111-150
The key's randomart image is:
+--[ RSA 2048]----+
| |
| . . |
| . . . .|
| . . + . . |
| S o = . |
| . . . ..|
| . E +|
| . O=|
| .o==@|
+-----------------+
Feb 18 01:26:06 : Please enter local user to store backups :
madhan
Feb 18 01:26:22 : Exchanging ssh keys with host 127.0.0.1
madhan@127.0.0.1's password:
Feb 18 01:26:30 : Successfully initialized localhost to store backups
Script to backup tonidocloud data
Usage :
 sudo /path/backup.sh <command>
 where <command> could be on of the following:
 	addtgt <user> <host> <tgtdir> 	- Adds the <tgtdir> in machine <user>@<host> as a valid backup directory
	rmtgt <index> 			- Removes the backup target at specified index.
 					  If index parameter is missing, a list of available targets will be shown to choose one from.
 	lstgts 				- Lists available backup directories
	crtbkup <index> 		- Create a new backup of tonidocloud at specified backup target index.
 					  If index parameter is missing, a list of available targets will be shown to choose one from.
	lstbkups <index> 		- List all backups under the specified target index.
					  If index parameter is missing, a list of available targets will be shown to choose one from.
	rmbkup <index1> <index2> 	- Removes index2 directory from index1 backup target.
		   			  If index parameters is missing, a lists of available targets and directories will be shown to choose one from.
	resbkup <index1> <index2> 	- Restores index2 directory from index1 backup target.
		 			  If index parameters is missing, a lists of available targets and directories will be shown to choose one from.

Add Backup Target

The backup tool has to have atleast one backup target before it can create and store backups. Even if you plan to store the backups on the local system, you still need to the local host as a backup target. When multiple backup target directories are added to the tool, the ssh keys are exchanged only the first time.

To add a backup target you need

  • a user
  • ip address of the remote host.
  • a directory to store backups ( and the above user should have write permissions)

Use the option addtgt to add a new backup target to the tool. The following snippet shows commands to add 2 backup targets.

Local host (madhan, 127.0.0.1, /backup)


Adding a localhost target
madhan@li111-150:/var/www/resources/backup$ sudo ./backup.sh addtgt madhan 127.0.0.1 /cloudbackup/
Feb 18 02:20:23 : Adding backup target : madhan@127.0.0.1:/cloudbackup/
Feb 18 02:20:25 : Added backup target : madhan@127.0.0.1:/cloudbackup

Remote host (cloud, 192.168.1.148, /backup)

Adding a remote host target
madhan@li111-150:/var/www/resources/backup$ sudo ./backup.sh addtgt cloud 192.168.1.148 /cloudbackup/
Feb 17 18:31:47 : Adding backup target : cloud@192.168.1.148:/cloudbackup/
Feb 17 18:31:47 : Exchanging ssh keys with host 192.168.1.148
cloud@192.168.1.148's password:
Feb 17 18:31:51 : Added backup target : cloud@192.168.1.148:/cloudbackup

Remove Backup Target

To remove a backup target use the option rmtgt. This option lists the available backup targets and prompts for the target to be deleted. Upon entering the target number, the tool deletes the target. When a target is deleted, the tool just removes pointer to the target from its internal list. The physical directory is not deleted. This allows admins to add the same target at later point of time with all the backups intact.

Note: The target number can also be specified from the command line

Removing a target
madhan@li111-150:/var/www/resources/backup$  sudo ./backup.sh rmtgt
 No Targets
-------------------------------------------------------------
 0) madhan@127.0.0.1:/cloudbackup
 1) cloud@192.168.1.148:/cloudbackup
-------------------------------------------------------------
Feb 17 18:41:20 : Select a backup target to remove from the above list :
1
Feb 17 18:41:37 : Selected backup target cloud@192.168.1.148:/cloudbackup
Feb 17 18:41:37 : Backup target removed : cloud@192.168.1.148:/cloudbackup

List Backup Targets

To list the available backup targets in the tool use the option lstgts.

Listing targets
madhan@li111-150:/var/www/resources/backup$  sudo ./backup.sh lstgts
 No Targets
-------------------------------------------------------------
 0) madhan@127.0.0.1:/cloudbackup
-------------------------------------------------------------

Create New Backup

To create a new backup use the option crtbkup.

Create Backup
madhan@li111-150:/var/www/resources/backup$ sudo ./backup.sh crtbkup
Feb 18 03:22:19 : Creating backup
 No Targets
-------------------------------------------------------------
 0) madhan@127.0.0.1:/cloudbackup
-------------------------------------------------------------
Select a backup target from the above list : 0
Feb 18 03:22:21 : Selected backup target madhan@127.0.0.1:/cloudbackup
sending incremental file list
5108a8b6bff4d/
5108a8b6bff4d/5108a8b6c26d2/
5108a8b6bff4d/5108a8b6c26d2/510d2ecb07217.dat
 42.55K 100% 9.33MB/s 0:00:00 (xfer#1, to-check=54/57)
5108a8b6bff4d/5108a8b6c26d2/510d2ecb08d48.dat

.....

5108a8b6bff4d/5108a8b6c26d2/51132eeb6a45a.dat
 174.84K 100% 241.84kB/s 0:00:00 (xfer#55, to-check=0/57)

sent 60.89M bytes received 1.06K bytes 24.36M bytes/sec
total size is 60.88M speedup is 1.00
tonidobak.log 100% 20KB 19.8KB/s 00:00

Note: The target number can also be specified from the command line.

List Backups

To list backups available on a particular backup target directory use the option lstbkups .

Listing Backups
madhan@li111-150:/var/www/resources/backup$ sudo ./backup.sh lstbkups
 No Targets
-------------------------------------------------------------
 0) madhan@127.0.0.1:/cloudbackup
-------------------------------------------------------------
Feb 18 03:26:39 : Select a target from above to list available backups :
0
Feb 18 03:27:03 : Selected backup target madhan@127.0.0.1:/cloudbackup
  No         Date                         Files         Size              Status              Path
---------------------------------------------------------------------------------------------------------------
  0)         03:22:21 2013-02-18          59M          44               COMPLETE            /cloudbackup/1361157741
---------------------------------------------------------------------------------------------------------------

Note: The target number can also be specified from the command line.

Delete Backup

To delete a backup target directory use the option rmbkup.

Deleting Backups
madhan@li111-150:/var/www/resources/backup$ sudo ./backup.sh rmbkup
 No Targets
-------------------------------------------------------------
 0) madhan@127.0.0.1:/cloudbackup
-------------------------------------------------------------
Feb 18 03:31:25 : Select a target from above to list available backups
0
Feb 18 03:31:28 : Selected backup target madhan@127.0.0.1:/cloudbackup
  No         Date                         Files         Size              Status              Path
---------------------------------------------------------------------------------------------------------------
  0)         03:22:21 2013-02-18          59M          44               COMPLETE            /cloudbackup/1361157741
---------------------------------------------------------------------------------------------------------------
Feb 18 03:31:30 : Select a backup directory
0
Feb 18 03:31:34 : Selected backup path /cloudbackup/1361157741
madhan@li111-150:/var/www/resources/backup$ sudo ./backup.sh lstbkups 0
Feb 18 03:32:01 : Selected backup target madhan@127.0.0.1:/cloudbackup
  No         Date                         Files         Size              Status              Path
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------

Note: The backup target number and backup target directory number can also be specified from the command line.

Restore Backup

To restore a backup from a particular backup target directory use the option resbkup.

Note: When a backup is restored, the cloud service will be stopped to restore the backup. Upon restoring the snapshot the service will be started again.

Restoring Backups
madhan@li111-150:/var/www/resources/backup$ sudo ./backup.sh resbkup
  No         Targets
-------------------------------------------------------------
  0)         madhan@127.0.0.1:/cloudbackup
-------------------------------------------------------------
Feb 18 03:42:00 : Select a target from above to list available backups
0
Feb 18 03:42:05 : Selected backup target madhan@127.0.0.1:/cloudbackup
  No         Date                         Files         Size              Status              Path
---------------------------------------------------------------------------------------------------------------
  0)         03:40:16 2013-02-18          59M          44               COMPLETE            /cloudbackup/1361158816
---------------------------------------------------------------------------------------------------------------
Feb 18 03:42:07 : Select a backup directory
0
Feb 18 03:42:15 : Selected backup path /cloudbackup/1361158816
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mongodb stop

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) utility, e.g. stop mongodb
mongodb stop/waiting
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mongodb start

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start mongodb
mongodb start/running, process 17363

Note: The backup target number and backup target directory number can also be specified from the command line.