From 0b425f5687c825d6987cdd72db4d813c73b5094c Mon Sep 17 00:00:00 2001 From: gospodar Date: Fri, 10 Feb 2023 16:36:51 +0100 Subject: [PATCH] Implement archiving and rsync placeholder --- backup.cfg | 3 +++ main.sh | 38 ++++++++++++++++++++++++++++---------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/backup.cfg b/backup.cfg index 1cc97dd..44514bf 100644 --- a/backup.cfg +++ b/backup.cfg @@ -4,6 +4,7 @@ # Please double check Your settings # -------------------------------------------------------- +enabled=false #enable main function www_backup=false # backup wwwroot www_dir='xyz' # wwwroot location @@ -17,6 +18,8 @@ apache=false # apache log backup nginx=false # nginx log backup log_purge=false # purge logs after backup +rsync_push=false # enable push to remote server +push_clean=false # clean backup file after push #Docker #Docker volumes #Syslogs diff --git a/main.sh b/main.sh index b8ddccb..44b20ab 100644 --- a/main.sh +++ b/main.sh @@ -23,8 +23,9 @@ source "$config" echo "Configuration file loaded" >&2 function makedir { -mkdir /tmp/backify-$(date +%Y%m%d_%H%M) -tmpdir='/tmp/backify-$(date +%Y%m%d_%H%M)' +timestamp=$(date +%Y%m%d_%H%M) +mkdir /tmp/backify-timestamp +tmpdir='/tmp/backify-timestamp' } function wwwbackup { @@ -78,15 +79,32 @@ if [ "$log_backup" = true ] then fi } +function push { + if [ "rsync_push" = true ] then + #Push + if [ "push_clean" = true ] then + rm /opt/backify-$timestamp.tar.gz + fi + fi +} + function runbackup { - # step 1 : create directory - makedir - # step 2 : wwwbackup - wwwbackup - # step 3 : vhostbackup - vhostbackup - # step 4: logbackup - logbackup + if [ "enabled" = true] then + # step 1 : create directory + makedir + # step 2 : wwwbackup + wwwbackup + # step 3 : vhostbackup + vhostbackup + # step 4: logbackup + logbackup + # archive data + echo "Creating backup archive..." >&2 + tar -czvf /opt/backify-$timestamp.tar.gz $tmpdir + # push data to server + push + echo "Voila, enjoy the rest of the day" >&2 + fi } runbackup \ No newline at end of file