forked from tbaldur/cyberpanel-mods
-
Notifications
You must be signed in to change notification settings - Fork 2
/
rclone_mariadb
34 lines (20 loc) · 1.19 KB
/
rclone_mariadb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
TIMESTAMP=$(date +"%Y-%m-%d")
MYSQL=/usr/bin/mysql
MYSQLDUMP=/usr/bin/mysqldump
echo "RCLONE backup (and encrypt) files to cloud storage"
echo "What is your mysql user with all privileges? (e.g. root)"
read MYSQL_USER
echo "What is your $MYSQL_USER password? (e.g. root password found in /usr/local/CyberCP/CyberCP/settings.py)"
read MYSQL_PASSWORD
echo "Where do you want to dump your backup on CyberPanel? (e.g. /home/mydomain.com/public_html/backup)"
read BACKUP_DIR
echo "Where do you want to dump your backup on Remote? (e.g. backup/dir = remote:backup/dir {remote = MEGA/GDRIVE, backup/dir = directory}) "
read REMOTE_DIR
mkdir -p "$BACKUP_DIR"
$MYSQLDUMP --user=$MYSQL_USER -p$MYSQL_PASSWORD --all-databases | gzip > "$BACKUP_DIR/backup-$TIMESTAMP.sql.gz"
# If you are only copying a small number of files (or are filtering most of the files) and/or have a large number of files on the destination then
# --no-traverse will stop rclone listing the destination and save time.
rclone copy --progress "$BACKUP_DIR/backup-$TIMESTAMP.sql.gz" remote:$REMOTE_DIR
echo ""
echo "Local backup at $BACKUP_DIR/backup-$TIMESTAMP.sql.gz, Remote backup at $REMOTE_DIR/backup-$TIMESTAMP.sql.gz"