WEBSITE AND MYSQL BACKUP SCRIPT

In information technology, a backup, or the process of backing up, refers to the copying and archiving of computer data so it may be used to restore the original after a data loss event. The verb form is to back up in two words, whereas the noun is backup.

Since a backup system contains at least one copy of all data worth saving, the data storage requirements can be significant. Organizing this storage space and managing the backup process can be a complicated undertaking. A data repository model can be used to provide structure to the storage. Nowadays, there are many different types of data storage devices that are useful for making backups. There are also many different ways in which these devices can be arranged to provide geographic redundancy, data security, and portability.

Before data are sent to their storage locations, they are selected, extracted, and manipulated. Many different techniques have been developed to optimize the backup procedure. These include optimizations for dealing with open files and live data sources as well as compression, encryption, and de-duplication, among others. Every backup scheme should include dry runs that validate the reliability of the data being backed up. It is important to recognize the limitations and human factors involved in any backup scheme



Backing up all your Website and MySQL databases one by one is a pain. Here is a small bash script I made to dump and compress all my databases to my Amazon s3 folder.

Here is what I use to make a backup library of Website directory & MySQL daily that will keep backups for 15 days.

MYSQL BACKUP SCRIPT


 #!/bin/bash  
 # Backup dan upload ke server backup secara manual  
 #  
 #  
 #  
 #  
 ##########################  
 # CONFIGURATION  
 ##########################  
 DESTDIR="yourdestbackup"  
 date=$(date +"%d-%b-%Y")  
 userdir=youruserdir  
 # for database  
 USER="youruser"  
 PASSWORD="yourpassword"  
 # EOF DATABASE  
 #DO NOT EDIT ANYTHING BELOW  
 # to create backup website files  
 tar cvzfP $DESTDIR/$userdir-homedir-$date.tar.gz /home/$userdir/public_html/  
 # to get list database user  
 databases=`mysql --user=$USER --password=$PASSWORD -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`  
 # Create dumps database  
 for db in $databases; do  
   if [[ "$db" != "information_schema" ]] && [[ "$db" != _* ]] ; then  
     echo "Dumping database: $db"  
     mysqldump --force --opt --user=$USER --password=$PASSWORD --databases $db > $DESTDIR/$db-$date.sql  
     gzip $DESTDIR/$db-$date.sql  
   fi  
 done  
 # delete old backups  
 find $DESTDIR -mtime +30 -exec rm -f {} \;  
Good luck!
Previous
Next Post »