Skip to content

Instantly share code, notes, and snippets.

@lolmaus
Last active December 16, 2015 14:49
Show Gist options
  • Save lolmaus/5451032 to your computer and use it in GitHub Desktop.
Save lolmaus/5451032 to your computer and use it in GitHub Desktop.
Backing up to Selectel using S3QL File extensions are added for syntax highlighting. Remove them if you gonna use this.
[selectel]
storage-url: swift://auth.selcdn.ru
backend-login: 12345
backend-password: qwertyUIOP
#!/bin/bash
SCRIPTS_FOLDER="/root/.selectel"
MOUNT_POINT="/mnt/selectel"
NOW=$(date +"%Y-%m-%d--%H-%M-%S")
WIKI_DEST="/var/backups/wiki/wiki.lolma.us-$NOW.tar.gz"
WIKI_SOURCE="/var/vhosts/wiki.lolma.us"
WIKI_ARCH="$MOUNT_POINT/lin.lolma.us/wiki"
AEGIR_SOURCE="/var/aegir/backups"
AEGIR_ARCH="$MOUNT_POINT/lin.lolma.us/aegir-sites"
echo "Creating a backup of the wiki"
tar -czf "$WIKI_DEST" "$WIKI_SOURCE"
echo "Mounting the remote filesystem"
$SCRIPTS_FOLDER/mount
echo "Storing the wiki backup"
mv "$WIKI_DEST" "$WIKI_ARCH"
echo "Storing Aegir sites backups (should be created on their own)"
#rsync -aPv --modify-window=60 --itemize-changes --stats --delete "$AEGIR_SOURCE" "$AEGIR_ARCH"
rsync -aPv --itemize-changes --stats --delete "$AEGIR_SOURCE" "$AEGIR_ARCH"
echo "Unmounting"
#$SCRIPTS_FOLDER/umount
echo "All done."
#!/bin/bash
BASE=$(dirname $0)
source "$BASE/vars"
# Redirect stdout and stderr into the system log
DIR=$(mktemp -d)
mkfifo "$DIR/LOG_FIFO"
logger -t s3ql -p local0.info < "$DIR/LOG_FIFO" &
exec > "$DIR/LOG_FIFO"
exec 2>&1
rm -rf "$DIR"
# Check and mount file system
su -s /bin/sh -c 'exec "$0" "$@"' "$USER" -- \
fsck.s3ql --batch --authfile "$BASE/$AUTHFILE" "$STORAGE_URL"
exec su -s /bin/sh -c 'exec "$0" "$@"' "$USER" -- \
mount.s3ql --authfile "$BASE/$AUTHFILE" "$STORAGE_URL" "$MOUNTPOINT"
#!/bin/bash
BASE=$(dirname $0)
source "$BASE/vars"
su -s /bin/sh -c 'exec "$0" "$@"' "$USER" -- umount.s3ql "$MOUNTPOINT"
STORAGE_URL="swift://auth.selcdn.ru/backups"
MOUNTPOINT="/mnt/selectel"
USER="root"
AUTHFILE="./authfile"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment