]> lifelog.hopto.org Git - LifeLog.git/commitdiff
Automated server backup to local machine.
authorwbudic <redacted>
Sun, 29 Aug 2021 00:02:49 +0000 (10:02 +1000)
committerwbudic <redacted>
Sun, 29 Aug 2021 00:02:49 +0000 (10:02 +1000)
backupDBLifeLog.sh

index 335ae3d4f416eab102b93f349ad42c5e4dda3118..71187e92b08a567575a45a9638de611b196863fd 100755 (executable)
@@ -8,9 +8,13 @@
 # Programed by: Will Budic
 # Open Source License -> https://choosealicense.com/licenses/isc/
 #Example crontab -e entry for every three hours.
-#crontab -> * */3 * * * ./backupDBLifeLog.sh > /dev/null 2>&1
+#crontab -> * */3 * * * /home/will/dev/backupDBLifeLog.sh > /dev/null 2>&1
 
-DIR="/home/will/Documents/dbLifeLog"
+export DISPLAY=":0"
+export XDG_RUNTIME_DIR=/run/user/$(id -u)
+export XAUTHORITY="/home/will/.Xauthority"
+export SSHPASS='N0-MA-E9-5E-4A-C6-MJ-2F'
+DIR="/home/will/backups/r2d2_dbLifeLog"
 NOW=`date +%Y%m%d`
 
 if [ ! -d "$DIR" ]; then
@@ -18,7 +22,7 @@ if [ ! -d "$DIR" ]; then
 fi
 cd $DIR
 
-sftp will@nuc:/home/will/thttpd_dev/dbLifeLog/ <<EOF
+sshpass -e sftp -oIdentityFile=~/.ssh/id_dsa -oBatchMode=no r2d2@192.168.1.20:/home/r2d2/dev/dbLifeLog/ <<EOF
 get *.db 
 exit
 EOF
@@ -30,8 +34,7 @@ EOF
 tar -czvf DB_LIFE_LOG_BACKUP_$NOW.tar *.db
 
 #Remove unecessary files.
-find $DIR -type f -name '*.tar' -mtime  1 -exec rm {} \; 
+find $DIR -type f -name '*.tar' -mtime +3 -exec rm -f {} \; 
 rm *.db
 
-
 exit