Edit Rename Changes History Upload Download Back to Top

sample backup scripts

Back to Backup Strategy, Using the Backup Server.

See also Recovering a service from backup.

Example script to backup a service to the backup server

Note that for non-sensitive data it's best to tar up the files and using rsync to copy them to the backup server because rsync will only move changes - even if it is one big file. For sensitive data, the backup should be encrypted, and because rsync does not perform so well on mashed up binary data, the backup should be compressed and moved using scp.

This script is an example only. For information on production versions, please contact the backup administrator.

#!/bin/sh

### CONFIGURATION


# Remote user
RUSER=bu-list

# Remote host
RHOST=backup.openskills.org

# Remote directory
RDIR=/var/openskills-backup/$RUSER

# List of files as seen from "/" directory
FILELIST=var/lib/mailman/*

# We let rsync do the compression during transmission
# so an ordinary .tar file will do.  The target file
# will keep the name of the source file.
TARFILE=/var/openskills-backup/bu-lists/daily-backup-lists.tar
TAR_OPTIONS="cf"
TARFILE_PERMS="640"

# p: preserve permissions (but not ownership, since that is
#    not possible unless run by the super user)
# u: update only if target is older (optional)
# See rsync(1) for more options.
RSYNC_OPTIONS="-up"


### Make the tar file and fix the perms

touch $TARFILE
chmod $TARFILE_PERMS $TARFILE
cd /
tar $TAR_OPTIONS $TARFILE $FILELIST


### Rsync the tar file to RHOST

rsync $RSYNC_OPTIONS $TARFILE $RUSER@$RHOST:$RDIR


### All done!


Edit Rename Changes History Upload Download Back to Top