Last active
December 16, 2015 14:49
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[selectel] | |
storage-url: swift://auth.selcdn.ru | |
backend-login: 12345 | |
backend-password: qwertyUIOP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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." | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BASE=$(dirname $0) | |
source "$BASE/vars" | |
su -s /bin/sh -c 'exec "$0" "$@"' "$USER" -- umount.s3ql "$MOUNTPOINT" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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