@@ -41,6 +41,7 @@ echo $backupfile >>$logfile
41
41
du -h ./backups/$backupfile
42
42
43
43
# remove older local backup files
44
+ # to change backups retained, change below +8 to whatever you want (days retained +1)
44
45
ls -t1 ./backups/backup* | tail -n +8 | sudo xargs rm -f
45
46
echo " last seven local backup files are saved in ~/IOTstack/backups"
46
47
@@ -59,32 +60,36 @@ if [ -f ./backups/dropbox ]; then
59
60
$dropboxuploader upload ./backups/$backupfile $dropboxfolder
60
61
61
62
# 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"
63
65
files=$( $dropboxuploader list $dropboxfolder | awk {' print $3 ' } | tail -n +2 | head -n -7)
64
66
65
- # write files to be deleted to logfile
67
+ # write files to be deleted to dropbox logfile
66
68
sudo touch $dropboxlog
67
69
sudo chown pi:pi $dropboxlog
68
70
echo $files | tr " " " \n" > $dropboxlog
69
71
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"
73
75
input=$dropboxlog
74
76
while IFS= read -r file
75
77
do
76
78
$dropboxuploader delete $dropboxfolder /$file
77
79
done < " $input "
78
80
79
- echo " deleted from cloud " >> $dropboxlog
81
+ echo " deleted from dropbox " >> $dropboxlog
80
82
81
83
fi
82
84
83
85
84
86
# cloud related - google drive
85
87
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"
88
93
fi
89
94
90
95
0 commit comments