Created
May 25, 2015 12:47
-
-
Save you-think-you-are-special/8b59a6dd6156e75d00f3 to your computer and use it in GitHub Desktop.
Backup website into cloud (Yandex Disk)
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 | |
GPG_COMMAND="gpg -c -z 0 --batch --passphrase XXXXXXXXXX" | |
FS_FILE=/tmp/$SERVER_NAME-fs.$TIME.tar.gz.gpg | |
MYSQL_FILE=/tmp/$SERVER_NAME-mysql.$TIME.sql.gz.gpg | |
# Archiving filesystem | |
tar -cz /etc /root /home | $GPG_COMMAND > $FS_FILE | |
# Archiving databases | |
mysqldump -u root --password=qwerty --all-databases | gzip | $GPG_COMMAND > $MYSQL_FILE | |
SERVER_NAME="server1" | |
TIME=`date +%Y-%b` | |
FS_FILE=/tmp/$SERVER_NAME-fs.$TIME.tar.gz | |
MYSQL_FILE=/tmp/$SERVER_NAME-mysql.$TIME.sql.gz | |
# Archiving filesystem | |
tar -czf $FS_FILE /etc /root /home | |
# Archiving databases | |
mysqldump -u root --password=qwerty --all-databases | gzip > $MYSQL_FILE | |
# Uploading to the cloud | |
curl --user USER:PASSWORD -T "{$FS_FILE,$MYSQL_FILE}" https://webdav.yandex.ru/ | |
# Cleanup | |
unlink $FS_FILE | |
unlink $MYSQL_FILE |
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
. . . | |
GPG_COMMAND="gpg -c -z 0 --batch --passphrase XXXXXXXXXX" | |
FS_FILE=/tmp/$SERVER_NAME-fs.$TIME.tar.gz.gpg | |
MYSQL_FILE=/tmp/$SERVER_NAME-mysql.$TIME.sql.gz.gpg | |
# Archiving filesystem | |
tar -cz /etc /root /home | $GPG_COMMAND > $FS_FILE | |
# Archiving databases | |
mysqldump -u root --password=qwerty --all-databases | gzip | $GPG_COMMAND > $MYSQL_FILE | |
. . . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment