First commit of the bash file.

This commit is contained in:
Ricardo
2023-10-18 16:54:51 +00:00
parent 88a63dde23
commit 8d694948ae

24
backing_web.sh Normal file
View File

@@ -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"