Implement archiving and rsync placeholder

This commit is contained in:
gospodar 2023-02-10 16:36:51 +01:00
parent 6ffbc54ea0
commit 0b425f5687
2 changed files with 31 additions and 10 deletions

View File

@ -4,6 +4,7 @@
# Please double check Your settings # Please double check Your settings
# -------------------------------------------------------- # --------------------------------------------------------
enabled=false #enable main function
www_backup=false # backup wwwroot www_backup=false # backup wwwroot
www_dir='xyz' # wwwroot location www_dir='xyz' # wwwroot location
@ -17,6 +18,8 @@ apache=false # apache log backup
nginx=false # nginx log backup nginx=false # nginx log backup
log_purge=false # purge logs after 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
#Docker volumes #Docker volumes
#Syslogs #Syslogs

22
main.sh
View File

@ -23,8 +23,9 @@ source "$config"
echo "Configuration file loaded" >&2 echo "Configuration file loaded" >&2
function makedir { function makedir {
mkdir /tmp/backify-$(date +%Y%m%d_%H%M) timestamp=$(date +%Y%m%d_%H%M)
tmpdir='/tmp/backify-$(date +%Y%m%d_%H%M)' mkdir /tmp/backify-timestamp
tmpdir='/tmp/backify-timestamp'
} }
function wwwbackup { function wwwbackup {
@ -78,7 +79,17 @@ if [ "$log_backup" = true ] then
fi fi
} }
function push {
if [ "rsync_push" = true ] then
#Push
if [ "push_clean" = true ] then
rm /opt/backify-$timestamp.tar.gz
fi
fi
}
function runbackup { function runbackup {
if [ "enabled" = true] then
# step 1 : create directory # step 1 : create directory
makedir makedir
# step 2 : wwwbackup # step 2 : wwwbackup
@ -87,6 +98,13 @@ function runbackup {
vhostbackup vhostbackup
# step 4: logbackup # step 4: logbackup
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 runbackup