Backup html folder, backup SQL Database and download locally

From rbachwiki
Revision as of 13:47, 15 June 2023 by Bacchas (talk | contribs)
Jump to navigation Jump to search

Master Script

echo "-----------------------------------"
echo "++++++++++ Running backup script, zipping dir and dump sql database ++++++++++"
echo ""
clientscripts/./client_run_backup_sql_zip.sh
sleep 5
echo "-----------------------------------"
echo "++++++++++ Download zip and sql files and copy to synology ++++++++++"
echo ""
clientscripts/./client_dlzipsql_cpto_synology.sh
sleep 5
echo "-----------------------------------"
echo "++++++++++ Delete zip and sql files on server ++++++++++"
clientscripts/./client_delete_zipsql.sh
echo "-----------------------------------"
echo "++++++++++ All scripts ran ++++++++++"

client_run_backup_sql_zip.sh

Running backup script, zipping dir and dump sql database

#!/bin/bash
ssh -i ~/.ssh/linode  root@10.1.1.1 /var/www/scripts/html_backup.sh
echo ""
echo "++++++++++++++++++ Finished running html backup script ++++++++++++++++"
echo ""
sleep 10
echo ""
echo "+++++++++++Running SQL Backup script ++++++"
ssh -i ~/.ssh/linode  root@10.1.1.1 /var/www/scripts/sql_backup.sh
echo ""
echo "+++++++++++++ Finish running SQL Backup script +++++++++++++++++"

clientscripts/./client_dlzipsql_cpto_synology.sh

Download zip and sql files and copy to synology

#!/bin/bash
scp -i ~/.ssh/linode  10.1.1.1:/var/www/backups/html/*.zip .
sleep 10
scp -i ~/.ssh/linode  10.1.1.1:/var/www/backups/sql/*.sql .
echo "+++++++++ done copying form Remote ++++++++++++++++++"
sleep 10
echo "+++++++++++++++ Copying .zip and sql files to stan ++++++++++++++++++++++++++++++"
scp -i ~/.ssh/synology *.zip admin@192.168.20.120:/volume1/Linode/client
scp -i ~/.ssh/synology *.sql admin@192.168.20.120:/volume1/Linode/client
echo " +++++++++++++++++++++++++ Done copying to stan ++++++++++++++ "
sleep 5
echo "++++++++++++++++ deleting zip and sql files from local ++++++++++++++++++++++"
rm *.zip
rm *.sql

client_delete_zipsql.sh

Delete zip and sql files on server

ssh -i ~/.ssh/linode root@10.0.0.4 /var/www/scripts/delete_backups.sh
#!/bin/bash

echo " ++++++++++ Deleting backup files ++++++++"
ls -la /var/www/backups/html
ls -la /var/www/backups/sql
sleep 5

rm /var/www/backups/html/*.zip
sleep 5
rm /var/www/backups/sql/*.sql

echo " +++++++++++++++++ done +++++++++++++++++"
ls -la /var/www/backups/html
ls -la /var/www/backups/sql