Professional Documents
Culture Documents
# Reference: http://www.rsnapshot.org/howto/1.2/rsnapshot-HOWTO.en.html
cd /tmp
wget http://www.rsnapshot.org/downloads/rsnapshot-1.3.0-1.noarch.rpm
rm -rf rsnapshot-1.3.0-1.noarch.rpm
cp -a /etc/rsnapshot.conf /etc/rsnapshot.conf.orig
vi /etc/rsnapshot.conf
# The directory /.snapshots will be where the local backups are taken.You can also
specify a different backup directory
snapshot_root /.snapshots/
#########
#Edit the line as shown and uncomment all other interval lines
interval daily 1
# Specify all directories to be backedup as shown below eg.if you want to backup
/etc and /var/www then make the following entries
backup /etc/ .
backup /var/www/ .
# Specify rysnc parameters as follows to enable softlink targets to be copied.
rsync_short_args -a -L
rsync_long_args --delete --numeric-ids --relative --delete-excluded --copy-links
# Please ensure that all fields are separated by tabs( and not spaces) otherwise
an error will be encountered
#########
cp -a /etc/my.cnf /etc/my.cnf.orig
vi /etc/my.cnf
####
# Add the following lines
[mysqldump]
user = root
password = <mysql_root_password>
host = localhost
####
mkdir -p /root/backup_scripts
vi /root/backup_scripts/backup_mysql.sh
#!/bin/sh
# To backup all databases
/usr/bin/mysqldump --all-databases > mysqldump_all_databases.sql
# To backup a selected database
/usr/bin/mysqldump db_name > db_name.sql
# To backup a selected table in a database
/usr/bin/mysqldump db_name table_name > table_name.sql
# Make the backup readable only by root
/bin/chmod 600 mysqldump_all_databases.sql
########
vi /etc/rsnapshot.conf
mv root_dsa /root/.ssh/
# On your backup server where you want to store your backups,do this as root
su
cd /tmp
/usr/sbin/useradd <backup_account>
/usr/bin/passwd <backup_account>
mkdir -p /home/<backup_account>/.ssh
rm -rf /tmp/root_dsa.pub
# Please ensure that the following entries are present in your backup servers
/etc/ssh/sshd_config file or else your public key authentication wont work
cp -a /etc/ssh/sshd_config /etc/ssh/sshd_config_backup_<todays_date>
vi /etc/ssh/sshd_config
#####
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
#####
mkdir -p /remote_backups/<backed_up_server_hostname>
exit
# Check if you can connect to your backup server using the newly generated keys
ssh -p22 -i /root/.ssh/root_dsa <backup_account>@<backup_server>
# Create an rsync script which will rysnc the backups to your remote backup server
vi /root/backup_scripts/remote_rsync.sh
#!/bin/sh
rsync -auz --delete -e "ssh -p22 -i /root/.ssh/root_dsa" /.snapshots/daily.0/
<backup_account>@<remote_backup_server>:/remote_backups/<backed_up_server_hostname
>/
####
# Comment out the existing cmd_postexec line and add this line to the
/etc/rsnapshot.conf file to enable rsync to run after rysync finishes the backup.
vi /etc/rsnapshot.conf
######
cmd_postexec /root/backup_scripts/remote_rsync.sh
######
# Run the following command to test your configuration.Fix issues till you get a
"Syntax OK" message.
/usr/bin/rsnapshot configtest
# This will print out a verbose list of the things it will do, without actually
doing them. To do a test run, run this command:
/usr/bin/rsnapshot -t daily
cd /tmp
wget http://www.rsnapshot.org/downloads/rsnapshot-1.3.0-1.noarch.rpm
rm -rf rsnapshot-1.3.0-1.noarch.rpm
cp -a /etc/rsnapshot.conf /etc/rsnapshot.conf.orig
vi /etc/rsnapshot.conf
# Ensure that the directory /.snapshots is created where the backups are taken
locally.You can also specify a different backup directory
snapshot_root /.snapshots/
vi /etc/rsnapshot.conf
#########
#Edit the line as shown and uncomment all other interval lines.This defines the
number of backups to be retained
interval daily 7
interval weekly 4
# Run the following command to test your configuration.Fix issues till you get a
"Syntax OK" message.
/usr/bin/rsnapshot configtest
# This will print out a verbose list of the things it will do, without actually
doing them. To do a test run, run this command:
/usr/bin/rsnapshot -t daily
# Setup of log rotation of rsnapshot logs on the server to be backed up and the
remote backup server
cd /etc/logrotate.d/
vi rsnapshot
###
/var/log/rsnapshot {
missingok
notifempty
copytruncate
}
###
chown root.root rsnapshot
chmod 644 rsnapshot