SERVER I.
Buat file dump.sh
#!/bin/bash
TheDATE=`date +%Y-%m-%d_`
W=`date +%A`
jamscript=`date +%Hh%Mm`
myfiles="mywebdb_"$TheDATE"_"$jamscript"_"$W".sql"
cd /var/www/bekap
/usr/bin/mysqldump -u myuser --all --password=mypassword mywebdb > $myfiles
if [ -e $myfiles ]; then
gzip -c $myfiles > $myfiles".gz"
fi
if [ -e $myfiles ]; then
rm -f $myfiles
fi
exit 0
Run the script at 06:00 and 18:00.
#chmod 755 dump.sh
#crontab -e
00 6 * * * /home/arisnb/dump.sh
00 18 * * * /home/arisnb/dump.sh
Create a username and password for your web. Example username is arisnb and password mypassword.
#htpasswd -c /var/www/bekap/.htpasswd arisnb
Create a file /var/www/bekap/.htaccess
AuthName "Please Login !!!"
AuthUserFile /var/www/bekap/.htpasswd
Require valid-user
ads : Please support me at Stop Dreaming Start Action :d
SERVER II (BACKUP)
Create a script for download, example download.sh
#!/bin/bash
TheDATE=`date +%Y-%m-%d_`
W=`date +%A`
jamscript="`date +%Hh%Mm`"
myfiles="mywebdb_"$TheDATE"_06h00m_"$W".sql.gz"
myfiles2="mywebdb_"$TheDATE"_18h00m_"$W".sql.gz"
cd /home/arisnb/bekap
if [ "$jamscript" = "06h30m" ]; then
wget -c --http-user=arisnb --http-passwd=mypassword https://10.10.10.1/bekap/$myfiles --no-check-certificate
fi
if [ "$jamscript" = "18h30m" ]; then
wget -c --http-user=arisnb --http-passwd=mypassword https://10.10.10.1/bekap/$myfiles2 -no-check-certificate
fi
exit 0
Run the script at 06:30 and 18:30.
#chmod 755 download.sh
#crontab -e
00 6 * * * /home/arisnb/download.sh
00 18 * * * /home/arisnb/download.sh
Check the backups files at /home/arisnb/bekap directory.
ads: Don't forget support me at Stop Dreaming Start Action
RSS Feed
Twitter
7:40 PM
tukang nggame