= S3QL Backup Script = Following is a modified version of the [http://www.rath.org/s3ql-docs/contrib.html#s3-backup-sh s3_backup.sh] script which which was provided by the Debian package at `/usr/share/doc/s3ql/examples/s3ql_backup.sh`. It expects a `/etc/s3ql/SERVERNAME` file listing directories to be backed up for each server and the SERVERNAME is expected to match the bucket name. {{{ #!/bin/bash # Abort entire script if any command fails set -e # This script assumes that bucketname and directory under # /media match and is also assumes that a file, with the # same name with a list of directories to backup exists # in /etc/s3ql # Check for bucket name / directory on standard input if [[ $1 ]]; then BUCKET=$1 elif [[ ! $1 ]]; then echo "Type the bucketname and then [ENTER]:" read bucket BUCKET=$bucket fi # Backup destination (storage url) storage_url="s3c://s.qstack.advania.com:443/$BUCKET" # Check that a list of diectories to backup exists at # /etc/s3ql/$BUCKET if [[ ! -f "/etc/s3ql/$BUCKET" ]]; then echo "You need to create /etc/s3ql/$BUCKET with a list of directories to backup" exit else BACKUP_LIST="/etc/s3ql/$BUCKET" fi # Recover cache if e.g. system was shut down while fs was mounted fsck.s3ql --backend-options="dumb-copy" --batch "$storage_url" # Create a temporary mountpoint and mount file system mountpoint="/tmp/s3ql_backup_$$" mkdir "$mountpoint" mount.s3ql --backend-options="dumb-copy" "$storage_url" "$mountpoint" # Make sure the file system is unmounted when we are done # Note that this overwrites the earlier trap, so we # also delete the lock file here. trap "cd /; umount.s3ql '$mountpoint'; rmdir '$mountpoint'; rm '$lock'" EXIT # Figure out the most recent backup cd "$mountpoint" last_backup=`python <