Hi All,
I just finished my RSync backup script and incase somebody might want to know how to go about that, here's my backup script and exclusion list.
First the backup script:
Here's my exclusion/inclusion script:
Hope this helps someone. However if you plan on syncing this backup through rsync with your local PC then I suggest you use a chrooted user which is locked in it's own home directory. That's where I create my rsync backup and from there I retrieve it to my windows box using Rsync too by using a public-private ssh key. Still testing the windows part of rsync.
I just finished my RSync backup script and incase somebody might want to know how to go about that, here's my backup script and exclusion list.
First the backup script:
Code:
#!/bin/sh
#
# (c) 2010 dreamline
#
# Crontab:
# 30 11,22 * * * <path to script>/rsync_backup.sh > /home/<username>/backup_log.txt
#
#
# Some RSync parameters explained:
# a = archive
# b = make backups
# E = preserve executability
# h = output numbers in a human-readable format
# v = verbose
# z = compress
# l = keep symlink
# L = copy symlink reference
# r = recurse into dirs
# m = remove empty dirs
# n = dry-run
# p = keep permissions
# t = keep modification times
# g = preserve groups
# o = preserve owner
# u = skip files that are newer on the receiver
SRC="/"
DST="/home/<username>"
/usr/bin/rsync -lavzrmpu --force --delete --delete-before --delete-excluded --exclude-from <path to script>/rsync_backuplist.txt "$SRC" "$DST"
chown -R <user>:<user> $DST # Here I chown everything to the chrooted user
chmod -R 744 $DST # Only give full access to chrooted user, others get read-only
Here's my exclusion/inclusion script:
Code:
#####################################################################
#
# (c) 2010 dreamline
#
####################################################################
# Backup complete /etc directory
####################################################################
+ /etc**
####################################################################
# Backup MySQL and Admin domains
####################################################################
+ /home
+ /home/mysql**
+ /home/admin**
####################################################################
# Backup DirectAdmin (do not backup mysql.conf because it contains
your da_admin password, also exclude updates and custombuild)
####################################################################
+ /usr
+ /usr/local
+ /usr/local/directadmin
+ /usr/local/directadmin/conf
- /usr/local/directadmin/conf/mysql*
- /usr/local/directadmin/custombuild*
- /usr/local/directadmin/updates*
+ /usr/local/directadmin/**
####################################################################
# Backup php.ini (PHP)
####################################################################
+ /usr/local/lib
+ /usr/local/lib/php.ini
####################################################################
# Backup config.inc.php (phpMyAdmin)
####################################################################
+ /var
+ /var/www
+ /var/www/html
+ /var/www/html/phpMyAdmin
+ /var/www/html/phpMyAdmin/config.inc.php
####################################################################
# Backup complete /root directory
####################################################################
+ /root**
####################################################################
# Exclude all the rest
####################################################################
- *
Hope this helps someone. However if you plan on syncing this backup through rsync with your local PC then I suggest you use a chrooted user which is locked in it's own home directory. That's where I create my rsync backup and from there I retrieve it to my windows box using Rsync too by using a public-private ssh key. Still testing the windows part of rsync.
Last edited: