{{NeedsUpdate}}[http://rsnapshot.org/ '''''rnapshotrsnapshot'''''] is an excellent backup application and has been around for a long time and is extremely stable.
Why are backups important? Well, hardware failures, accidental file deletion(s), files become corrupted, etc.. Backups can help recover data where applications are being updated/upgraded. Enough reasons?
* Using a "terminal" session, login in using the "root" user ID.
* The "device name" of the drive needs to be determined.
<blockquote>Enter the following command:
{{Code|dmesg}}
</blockquote>
<blockquote>Enter the following command: dmesg The following information is displayed:{{Text|Text=<pre>[11122.304178] usb 2-4: new high-speed USB device number 5 using ehci_hcd
[11122.422152] usb 2-4: New USB device found, idVendor=0bc2, idProduct=3320
[11122.422165] usb 2-4: New USB device strings: Mfr=2, Product=3, SerialNumber=1
:'''Please Note: THIS WILL ERASE ALL DATA ON /dev/sdb1, MAKE SURE THIS IS THE CORRECT USB DRIVE AND NOT ANOTHER DRIVE.'''
<blockquote>The following information is displayed:{{Text|Text=<pre>mke2fs 1.42.5 (29-Jul-2012)
fs_types for mke2fs.conf resolution: 'ext3'
Filesystem label=usbdisk
.
.
Writing superblocks and filesystem accounting information: done}}</blockquotepre>
* Whenever a drive is formatted in Linux, about 5% is reserved of the total space on the drive for the operating system to continue using the hard drive to operate, even if it gets full. This is totally unnecessary for a USB external hard drive if it stores only data and not to run an operating system.
<blockquote> Enter the following to remove the reserved space:{{Code| tune2fs -m 0 /dev/sdb1}}</blockquote><blockquote>The following information is displayed:{{Text|Text= tune2fs 1.42.5 (29-Jul-2012) Setting reserved blocks percentage to 0% (0 blocks)}}
* The external drive is now ready for use.
* In the previous section the device name found found via the "dmesg" command. The device name found was "sdb1".
* We set the set the external drive's "label". It was set to "usbdisk".
<blockquote> To find the label at anytime via the "root" user ID enter:{{Code| e2label /dev/sdb1}}</blockquote><blockquote>The following information is displayed:{{Text|Text= usbdisk}}</blockquote>
Both methods of mounting will be controlled by the server's "fstab" configuration file. The fstab (a.k.a. file systems table) file is a system configuration file containing lists of available disks and disk partitions, and indicates how they are to be initialized or otherwise integrated into a system's file system. When the "mount" command is used, the fstab file is read to determine which options should be used when mounting a specified device.
* Navigate to the "etc" directory with the "cd" command and make a backup of the current fstab file.
<blockquote>{{Code| cd /etc cp /fstab /fstab_bak}}</blockquote>
* Using a preferred file editor (i.e. vi, nano), open the fstab file.
<blockquote>{{Code|nano fstab}}</blockquote>
* Near the bottom of the and after the other fstab entries, add the following:
* Find the "BACKUP INTERVALS" section and change the line items. What does this all mean? The "#" character at the beginning of each line means the configuration line item will not be enabled. Remove the "#" character as required. For example, when enabled the "interval daily" line will be active and 7 days of backups will be kept.
* Find the "GLOBAL OPTIONS" section. This section defines how much information will be saved in the rsnapshot "log" file.
4 Extra Verbose Show extra verbose information
5 Debug mode Everything
<blockquote>Change the following options as required:{{Text|Text= verbose 3 loglevel 3}}</blockquote>
* Find the "logfile" line and change the line item. After rsnapshot has completed backups this is where the resulting "log" file is stored. Change this line as required.
* Find the "BACKUP POINTS / SCRIPTS" section. Add changes as seen below. This is the section that defines the "key directories" that will be backed up. Please note the "localhost/", this represents the server that it being backed up. "localhost/" is a default name given to the current server. Change this name as required, say "amahiBox/"?
===Automate Backups Test the Configuration Changes ===* Now the changes to the rsnapshot configuration file have to be tested. rsnapshot has a feature to test changes to make sure things have been setup correctly.
A "root" user "cron job" could be created * Enter the following on the command-line to perform backupsinitiate the test.
:crontab -l > cronjobs rsnapshot configtest}}
* When the test completes the following should be displayed:nano cronjobs
add to this file for running rsnapshot and a weekly email report on rsnapshot: Syntax OK
:0 */4 * * * /usr/bin/If an error occurs the rsnapshot hourlyconfiguration file will need to be checked.
:30 23 * * * /usr/bin/rsnapshot daily===Automate Backups ===Backups can be automated by creating a "cron job" that can be executed by the system at predetermined intervals.
* Using a "terminal" session and "root" user ID a "cron job" configuration can be created to perform automated backups.Create a "cronjobs" text file as follows:00 23 * * 1 /usr/bin/rsnapshot weekly crontab -l > cronjobs
:30 22 1 * * /usr/bin/rsnapshot monthlyUsing a favourite text editor open the cronjobs file.
Save the file nano cronjobs
* Add to the cronjobs file for rsnapshot:crontab cronjobs
Rsnapshot should now be operational.
=== Test the Configuration Changes === 0 */4 * * * /usr/bin/rsnapshot hourly 30 23 * * * /usr/bin/rsnapshot daily 00 23 * Now the changes to the * 1 /usr/bin/rsnapshot configuration file have to be tested. weekly 30 22 1 * * /usr/bin/rsnapshot has a feature to test changes to make sure things have been setup correctly.monthly
* Enter Save the following on cronjobs file.* Now update the command-line to initiate "root" user IDs "crontab" with the test.<blockquote>{{Code|rsnapshot configtest}}</blockquote>following:
* When the test completes the following should be displayed:<blockquote>{{Text|Text=Syntax OK crontab cronjobs}}</blockquote>
* If an error occurs Reboot the server and rsnapshot configuration file will need to be checkedoperational.
===Email reporting===
* To email a report of backups:
for email reporting on your backups:: cp /usr/share/doc/rsnapshot*/utils/rsnapreport.pl /root : chmod 744 rsnapreport.pl '''*''' above indicates an rsnapshot version number
* Add the following to crontabfor a weekly email report on rsnapshot:
'''Please Note:00 22 * * 6 /usr/bin/rsnapshot du >> /root/rsnapreport | nail –r "somereturnadress@provider''' The above information maybe out of date due to technology changes.com" -s"HDA backup report" -S smtp=smtpPlease feel to update as required.yourprovider.com youremail@provider.com < /root/rsnapreport
===Make your backups available on clients (READ ONLY)===
Create a //hda/backup share in the HDA webinterface
Unfortunately mounting an NFS share in fstab did not work on my machine after a reboot, so I chose an alternative configuration that mounts the share later in the booting process:
: nano /etc/rc.local
Add
: mount -r -t nfs localhost:/media/usbdisk/.private/.snapshots/ /var/hda/files/backup/