|Version 19 (modified by ejhernandez@…, 4 years ago) (diff)|
A well designed backup routine is a must for any reliable system. Hardware failures, software bugs or human mistakes can leave your system down or with missing files. This guide shows you how to create daily backups using rdiff-backup. Incremental backups are used as they store only the changes in your system state from day-to-day and are therefore small and quick to run. If a disaster occurs, restoring your backups will help return your system to its normal operational condition.
A choice you must make is whether to create and store the backup locally or remotely. This guide covers only local backup as there are ongoing efforts to create an enterprise-level backup module for eBox Platform that will cater for your remote backup needs.
The use of a second computer or storage device provides a higher level of protection due to the physical separation of the machines. A hardware failure, software error or security breach in the main server doesn't affect the integrity of the backup. To minimize the risk of being compromised a backup server should be dedicated to the role and not run any additional services other than those required for the backup routine. Having two non-dedicated servers backup each other is definitely a bad idea as a compromise in one can lead to a compromise in the other.
The easiest way to make backups is to have an additional hard disk attached to, or installed in the server. This is usually identified as /dev/sdx. The first thing you have to do is to create a partition on the hard disk and put a file system on it.
The /proc/partitions file contains details of the hard disks and their partitions. In this example the additional disk is /dev/sdb, and in this case the disk doesn't have any partitions.
% cat /proc/partitions major minor #blocks name 8 0 8388608 sda <- your first hard disk 8 1 248976 sda1 <- the first partition on the first hard disk 8 2 8136922 sda2 <- the second partition on the first hard disk 8 16 1048576 sdb <- your second hard disk without partitions 254 0 4194394 dm-0 <- lvm volume 254 1 524288 dm-1 <- lvm volume 254 2 2097152 dm-2 <- lvm volume
Now use cfdisk to create a single partition using the entire disk:
% cfdisk /dev/sdb
You use the menu shown at the foot of the screen to create a partition:
- Select [ New ].
- Select [ Primary ] partition type.
- Accept the default Size (in MB): which in this example is the entire disk.
- Save changes to the partition table with [ Write ].
- Confirm the changes with yes.
- Select [ Quit ].
Now you can verify the newly created partition is listed as sdb1:
% cat /proc/partitions major minor #blocks name 8 0 8388608 sda <- your first hard disk 8 1 248976 sda1 <- the first partition on the first hard disk 8 2 8136922 sda2 <- the second partition on the first hard disk 8 16 1048576 sdb <- your second hard disk 8 17 1044193 sdb1 <- the recently created partition 254 0 4194394 dm-0 <- lvm volume 254 1 524288 dm-1 <- lvm volume 254 2 2097152 dm-2 <- lvm volume
It is time to create a file system on the new partition, be very careful because creating the file system on the wrong partition will delete all the contents in that partition. It is recommended that you choose ext3 with the dir_index option for better performance.
% mkfs.ext3 -O dir_index /dev/sdb1 Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 65280 inodes, 261048 blocks 13052 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=268435456 8 block groups 32768 blocks per group, 32768 fragments per group 8160 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376 Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 31 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
Now you create a mount point and mount the partition on it.
% mkdir /mnt/backup % mount -t ext3 /dev/sdb1 /mnt/backup
Next create a directory for the backups, following the schema, hostname-backup:
% mkdir /mnt/backup/ebox-backup
It is time to install rdiff-backup:
% apt-get install rdiff-backup
Now create your first backup:
% rdiff-backup --exclude /mnt/backup --exclude /dev --exclude /proc --exclude /sys / /mnt/backup/ebox-backup/
Next check the status of the backup:
% rdiff-backup -l /mnt/backup/ebox-backup Found 0 increments: Current mirror: Wed May 20 21:56:32 2009
This backup can be automated with a script like this one. Save it in /etc/cron.daily/ebox_backup, make it executable and it will be run every night.
% wget http://svn.ebox-platform.com/ebox-platform/trunk/extra/ebox_backup % mv ebox_backup /etc/cron.daily/ebox_backup % chmod a+x /etc/cron.daily/ebox_backup
Don't forget to set the BACKUP, LOG and MAXAGE variables to the proper values for your environment. You can also use the pre-commands and post-commands to mount and umount the device for increased security, uncomment those lines and set the paths as needed.
- ebox_backup_01.png (17.2 KB) - added by jsalamero@… 4 years ago.
- ebox_backup_02.png (16.9 KB) - added by jsalamero@… 4 years ago.
- ebox_backup_03.png (16.4 KB) - added by jsalamero@… 4 years ago.
- ebox_backup_04.png (17.7 KB) - added by jsalamero@… 4 years ago.
- ebox_backup_05.png (17.5 KB) - added by jsalamero@… 4 years ago.
- ebox_backup_06.png (17.3 KB) - added by jsalamero@… 4 years ago.