Skip to content

Commit d1996e4

Browse files
authored
Updated docker_backup.sh with rclone synching
rclone now syncs the local backup files to gdrive Edited some working to make things clearer
1 parent 072bb53 commit d1996e4

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

scripts/docker_backup.sh

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ echo $backupfile >>$logfile
4141
du -h ./backups/$backupfile
4242

4343
#remove older local backup files
44+
#to change backups retained, change below +8 to whatever you want (days retained +1)
4445
ls -t1 ./backups/backup* | tail -n +8 | sudo xargs rm -f
4546
echo "last seven local backup files are saved in ~/IOTstack/backups"
4647

@@ -59,32 +60,36 @@ if [ -f ./backups/dropbox ]; then
5960
$dropboxuploader upload ./backups/$backupfile $dropboxfolder
6061

6162
#list older files to be deleted from cloud (exludes last 7)
62-
echo "getting older filenames to be deleted from cloud"
63+
#to change dropbox backups retained, change below -7 to whatever you want
64+
echo "getting older filenames to be deleted from dropbox"
6365
files=$($dropboxuploader list $dropboxfolder | awk {' print $3 '} | tail -n +2 | head -n -7)
6466

65-
#write files to be deleted to logfile
67+
#write files to be deleted to dropbox logfile
6668
sudo touch $dropboxlog
6769
sudo chown pi:pi $dropboxlog
6870
echo $files | tr " " "\n" >$dropboxlog
6971

70-
#delete files from cloud as per logfile
71-
echo "deleting files from cloud - last 7 files are kept"
72-
echo "if less than 7 files are in cloud you wil see FAILED message below"
72+
#delete files from dropbox as per logfile
73+
echo "deleting files from dropbox - last 7 files are kept"
74+
echo "if less than 7 files are in dropbox you wil see FAILED message below"
7375
input=$dropboxlog
7476
while IFS= read -r file
7577
do
7678
$dropboxuploader delete $dropboxfolder/$file
7779
done < "$input"
7880

79-
echo "deleted from cloud" >>$dropboxlog
81+
echo "deleted from dropbox" >>$dropboxlog
8082

8183
fi
8284

8385

8486
#cloud related - google drive
8587
if [ -f ./backups/rclone ]; then
86-
echo "uploading to Google Drive"
87-
rclone -P copy ./backups/$backupfile gdrive:/IOTstackBU/
88+
echo "synching to Google Drive"
89+
echo "latest 7 backup files are kept"
90+
#sync local backups to gdrive (older gdrive copies will be deleted)
91+
rclone sync -P ./backups --include "/backup*" gdrive:/IOTstackBU/
92+
echo "synch with Google Drive complete"
8893
fi
8994

9095

0 commit comments

Comments
 (0)