Created
July 16, 2019 20:44
-
-
Save marianmirzacu/db465e0127cf12046c0c7f94d85e583b to your computer and use it in GitHub Desktop.
archive each DB and upload to onedrive (or other cloud storage) / archive and upload to onedrive (or other cloud storage) the whole /var/www folder
This file contains 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 | |
# some inspiration https://mensfeld.pl/2013/04/backup-mysql-dump-all-your-mysql-databases-in-separate-files/ | |
TIMESTAMP=$(date +"%F") | |
BACKUP_DIR="/root/backupdb/$TIMESTAMP" | |
MYSQL_USER="" | |
MYSQL=/usr/bin/mysql | |
MYSQL_PASSWORD="" | |
MYSQLDUMP=/usr/bin/mysqldump | |
mkdir -p "$BACKUP_DIR" | |
databases=`$MYSQL --user=$MYSQL_USER -p$MYSQL_PASSWORD -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|performance_schema|mysql)"` | |
for db in $databases; do | |
$MYSQLDUMP --user=$MYSQL_USER -p$MYSQL_PASSWORD --single-transaction --skip-lock-tables --databases $db | gzip > "$BACKUP_DIR/$db.gz" | |
done | |
rclone copy /root/backupdb/ onedrive:backup/dbs/ | |
rm -rf /root/backupdb/* | |
zip -rq "$TIMESTAMP".zip /var/www/* | |
rclone copy "$TIMESTAMP".zip onedrive:backup/files/ | |
rm "$TIMESTAMP".zip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment