Archive for May, 2010

Simple Linux Backup Method

Thursday, May 13th, 2010

For a simple Linux backup solution, I often use rsync.

You need to identify the file systems that need to be backed up. From the command line:

df -h

As a side note you should create a separate file system for your applicaton. RHEL or Linux does not normally do this for you. The advantage to doing this is, it is much easier to upgrade the operating system when your application files are not stored on the root file system.

Back to the task at hand, let’s say you added an extra disk to your server and have it mounted at /backup. You can run rsync from the command line:

rsync -aPv --one-file-system / /backup/root/

The above command should backup your root file system to /backup/root/. I usually like to add dates to these backup directory so I can restore a file from a point in time. The -P rsync option gives you verbose progress information. This is great when you run it interactively.

You can automate this command by putting it into a shell script.

# create file: /etc/cron.daily/backup.sh

#!/bin/bash

/usr/bin/rsync -av --one-file-system / /backup/root/

You will need to set the execute bit on the newly created backup.sh script

chmod +x /etc/cron.daily/backup.sh

Once you have created /etc/cron.daily/backup.sh it should be run every day by the Linux cron.