25 lines
961 B
Bash
25 lines
961 B
Bash
![]() |
#!/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"
|