#!/bin/bash
SCRIPTDIR=`dirname $0`
# The '--dry-run' will make sure the script won't really do
# anything. Comment it only after carefully reviewing
# the output
DEBUG_SWITCHES="--dry-run"
# The following switches will use "reduced redundancy" backup
DEBUG_SWITCHES="--dry-run"
# The following switches will use "reduced redundancy" backup
# (cheaper) and will delete files from backup when removed
# locally. The files.exclude contains file patterns to exclude
# from backup
COMMON_SWITCHES="--rr --delete-removed --rexclude-from=$SCRIPTDIR/files.exclude $DEBUG_SWITCHES"
echo "Running $0"echo Backup started at `date`
COMMON_SWITCHES="--rr --delete-removed --rexclude-from=$SCRIPTDIR/files.exclude $DEBUG_SWITCHES"
echo "Running $0"echo Backup started at `date`
# The following will cause printing of the command before
# executing it. Useful for logging
set -o xtrace
# s3cmd command for each dir I need to backup.
# s3cmd command for each dir I need to backup.
# Need to replace "bucket" with real bucket name
s3cmd sync $COMMON_SWITCHES $DEBUG_SWITCHES /mnt/vg1/lv0/users/ s3://bucket/users/
s3cmd sync $COMMON_SWITCHES /mnt/vg1/lv0/media/Audio/ s3://bucket/media/Audio/
s3cmd sync $COMMON_SWITCHES /mnt/vg1/lv0/media/Music/ s3://bucket/media/Music/
s3cmd sync $COMMON_SWITCHES /mnt/vg1/lv0/media/Pictures/ s3://bucket/media/Pictures/set +o xtrace
echo Backup finished at `date`
Here is an example for my files.exclude. It should reside in the same dir as the script above:
# Exclude files start with "._" and .DS_Store (for Mac OSX)
(^|/)\._[^/]*$
(^|/)\.DS_Store$
s3cmd sync $COMMON_SWITCHES /mnt/vg1/lv0/media/Audio/ s3://bucket/media/Audio/
s3cmd sync $COMMON_SWITCHES /mnt/vg1/lv0/media/Music/ s3://bucket/media/Music/
s3cmd sync $COMMON_SWITCHES /mnt/vg1/lv0/media/Pictures/ s3://bucket/media/Pictures/set +o xtrace
echo Backup finished at `date`
Here is an example for my files.exclude. It should reside in the same dir as the script above:
# Exclude files start with "._" and .DS_Store (for Mac OSX)
(^|/)\._[^/]*$
(^|/)\.DS_Store$
No comments:
Post a Comment