Files
Nginx_webNsql_backup/backing_web.sh

25 lines
961 B
Bash
Raw Normal View History

2023-10-18 16:54:51 +00:00
#!/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"