Changes between Version 5 and Version 6 of S3QLBackup
- Timestamp:
- Oct 14, 2015, 2:51:11 PM (3 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
S3QLBackup
v5 v6 23 23 # S3 server URL 24 24 SERVER="s3c://s.qstack.advania.com:443" 25 # mount directory for s3ql file systems26 MOUNT="/media/s3ql"27 # optional base source directory for for files to28 # backup, this is used because all the servers are29 25 # rsync command 30 26 RSYNC="rsync -aHAXx --delete-during --delete-excluded --partial -v" 27 # mount directory for s3ql file systems 28 S3QL_MOUNT="/media/s3ql" 29 # mount directory for sshfs file systems 30 SSHFS_MOUNT="/media/sshfs" 31 32 # check the $S3QL_MOUNT directory exists 33 if [[ ! -d "$S3QL_MOUNT" ]]; then 34 echo "$S3QL_MOUNT doesn't exist" 35 exit 1 36 fi 37 38 # check the $SSHFS_MOUNT directory exists 39 if [[ ! -d "$SSHFS_MOUNT" ]]; then 40 echo "$SSHFS_MOUNT doesn't exist" 41 exit 1 42 fi 31 43 32 44 # Check for bucket name / directory on standard input … … 39 51 fi 40 52 41 # sshfs mounted at /media/server-name42 SOURCE="/media/$BUCKET"43 44 53 # Check that a list of diectories to backup exists at 45 54 # $CONFIG_DIR/$BUCKET 46 55 if [[ ! -f "$CONFIG_DIR/$BUCKET" ]]; then 47 56 echo "You need to create $CONFIG_DIR/$BUCKET with a list of directories to backup" 48 exit 57 exit 1 49 58 else 50 59 BACKUP_LIST="$CONFIG_DIR/$BUCKET" 60 fi 61 62 # sshfs mounted at /media/server-name 63 SSHFS_SOURCE="$SSHFS_MOUNT/$BUCKET" 64 if [[ -d "$SSHFS_SOURCE" ]]; then 65 # mount the sshfs 66 mnt-sshfs $BUCKET && \ 67 echo "Success mounting $SSHFS_MOUNT/$BUCKET" || \ 68 { echo "Problem mounting $SSHFS_SOURCE" ; exit 1 ; } 69 else 70 echo "$SSHFS_SOURCE doesn't exist" 71 exit 1 72 fi 73 74 # check the bucket exists 75 if [[ -d "$S3QL_MOUNT/$BUCKET" ]]; then 76 # mount the s3ql directory 77 mnt-s3ql $BUCKET && \ 78 echo "Success mounting $S3QL_MOUNT/$BUCKET" || \ 79 { echo "Problem mounting $S3QL_MOUNT/$BUCKET" ; exit 1 ; } 80 else 81 echo "$S3QL_MOUNT/$BUCKET doesn't exist" 82 exit 1 51 83 fi 52 84 … … 58 90 59 91 # Mount file system 60 #mount.s3ql --backend-options="dumb-copy" "$SERVER/$BUCKET" "$ MOUNT/$BUCKET"92 #mount.s3ql --backend-options="dumb-copy" "$SERVER/$BUCKET" "$S3QL_MOUNT/$BUCKET" 61 93 62 94 # Figure out the most recent backup 63 cd "$ MOUNT/$BUCKET"95 cd "$S3QL_MOUNT/$BUCKET" 64 96 LAST_BACKUP=`python <<EOF 65 97 import os … … 72 104 # Duplicate the most recent backup unless this is the first backup 73 105 NEW_BACKUP=`date "+%Y-%m-%d_%H:%M:%S"` 74 if [ -n "$LAST_BACKUP"]; then106 if [[ -n "$LAST_BACKUP" ]]; then 75 107 echo "Copying $LAST_BACKUP to $NEW_BACKUP..." 76 108 s3qlcp "$LAST_BACKUP" "$NEW_BACKUP" … … 89 121 # "/home/my_username/" "./$NEW_BACKUP/" 90 122 91 if [[ -d "$MOUNT/$BUCKET" ]]; then 92 if [[ ! -d "$MOUNT/$BUCKET/$NEW_BACKUP" ]]; then 93 echo "$MOUNT/$BUCKET/$NEW_BACKUP doesn't exist so creating it" 94 mkdir -p "$MOUNT/$BUCKET/$NEW_BACKUP" 95 fi 96 for dir in $(<${BACKUP_LIST}); do 97 mkdir -p "$MOUNT/$BUCKET/$NEW_BACKUP$dir/" 98 $RSYNC "$SOURCE$dir/" "$MOUNT/$BUCKET/$NEW_BACKUP$dir/" 99 done 100 else 101 echo "$MOUNT/$BUCKET doesn't exist - something has gone horribly wrong" 102 exit 123 if [[ ! -d "$S3QL_MOUNT/$BUCKET/$NEW_BACKUP" ]]; then 124 echo "$S3QL_MOUNT/$BUCKET/$NEW_BACKUP doesn't exist so creating it" 125 mkdir -p "$S3QL_MOUNT/$BUCKET/$NEW_BACKUP" || \ 126 { echo "Problem making $S3QL_MOUNT/$BUCKET/$NEW_BACKUP" ; exit 1 ; } 103 127 fi 128 for dir in $(<${BACKUP_LIST}); do 129 mkdir -p "$S3QL_MOUNT/$BUCKET/$NEW_BACKUP$dir/" || \ 130 { echo "Problem making $S3QL_MOUNT/$BUCKET/$NEW_BACKUP$dir/" ; exit 1 ; } 131 $RSYNC "$SSHFS_SOURCE$dir/" "$S3QL_MOUNT/$BUCKET/$NEW_BACKUP$dir/" || \ 132 { echo "Problem with $RSYNC $SSHFS_SOURCE$dir/ $SSHFS_MOUNT/$BUCKET/$NEW_BACKUP$dir/" ; exit 1 ; } 133 done 104 134 105 135 # Make the new backup immutable … … 113 143 # be installed, and it *may* also not have the .py ending. 114 144 #expire_backups --use-s3qlrm 1 7 14 31 90 180 360 145 146 # unmount s3ql first 147 #umnt-s3ql $BUCKET 148 #umnt-sshfs $BUCKET 115 149 }}}