diff --git a/backing_web.sh b/backing_web.sh new file mode 100644 index 0000000..293d665 --- /dev/null +++ b/backing_web.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +DEST="/home/user/backups/daily/latest" # Backup folder +SOURCE="/usr/share/nginx/web_folder" # Source of the website folder + +echo -e "Stoping webserver and starting backup procedure...\n" + +systemctl stop nginx.service # Stop nginx + +rm -rf $DEST/* & # Clean destination folder first +remove=$! # get the pid number of the cleaning command +wait $remove # and wait for it to finish + +mysqldump --user user --password=password > $DEST/data_latest.sql & # Get the database to destination +dump=$! # get the pid number of the database command +wait $dump # and wait for it to finish + +cp -r $SOURCE $DEST # Copy the website folder to destination +copy=$! # get the pid number of the copy command +wait $copy # and wait for it to finish + +systemctl start nginx.service # Start nginx + +echo -e "Website backed up\nWebserver back online.\n"