Last active
January 6, 2020 03:53
-
-
Save thecancerus/1574749f76377299eb7302721082b67e to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
# Back up Script to Daily Full Backups | |
# Source: | |
# Author: Amit | |
DAY=$(date +"%Y%m%d") | |
MONTH=$(date +"%Y%m") | |
YEAR=$(date +"%Y") | |
YDAY=$(date -d '-1 day' '+%Y%m%d') | |
YMONTH=$(date -d '-1 day' '+%Y%m') | |
YYEAR=$(date -d '-1 day' '+%Y') | |
DEST="/var/www/backups/db/fullbackup/$YEAR/$MONTH/$DAY" | |
YDEST="/var/www/backups/db/fullbackup/$YYEAR/$YMONTH/$YDAY" | |
mkdir -p $DEST | |
if [ ! -f "/var/www/backups/s3sync/db/full/$YDAY/$YDAY.tar.gz" ]; then | |
if [ -d "$YDEST" ]; then | |
tar -czf /var/www/backups/s3sync/db/full/$YDAY/$YDAY.tar.gz -C /var/www/backups/db/fullbackup/$YYEAR/$YMONTH $YDAY | |
rm -rf $YDEST | |
fi | |
else | |
if [ -d "$YDEST" ]; then | |
rm -rf $YDEST | |
#rm -f /var/www/backups/s3sync/db/full/$YDAY/$YDAY.tar.gz | |
fi | |
fi | |
mariabackup --backup --no-lock --target-dir=$DEST | |
#move current day as well to the sync folder | |
mkdir -p /var/www/backups/s3sync/db/full/$DAY | |
tar -czf /var/www/backups/s3sync/db/full/$DAY/$DAY.tar.gz -C /var/www/backups/db/fullbackup/$YEAR/$MONTH $DAY | |
#split /var/www/backups/s3sync/db/full/$DAY/$DAY.tar.gz --bytes=500m --suffix-length=4 --numeric-suffix /var/www/backups/s3sync/db/full/$DAY/$DAY.tar.gz. | |
#mariabackup --backup --stream=xbstream | gzip > /var/www/database_backup/$DATE.gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment