Raspberry Pi Automatic Backup Mysql and Website

Got me this beauty lately , the Raspberry PI Model B

Raspberry Pi

I am using it right now as a headless device for backups and to update the xbmc library remotely.

Here are short instructions to set up a automated mysql and website backup with crontab’s

 

Lets start with the Website backup , we just write a small shell script, first log into your terminal on your raspberry pi.

then we write:

  • sudo nano /home/pi/backup.sh

 

Now we come to the bash code:

[download id=”20″ format=”2″]

Copy paste that file or you can download it to your pi with the wget command:

wget -O /home/pi/backup.sh https://dl.dropboxusercontent.com/u/1437823/Cache/raspb/backup.sh

by pi being your local user, pi is the default user, You will just have to edit the directory in the shell script.

Now to test if it ist working run

sudo bash /home/pi/backup.sh

and your script will execute.

 

The script itself makes a tar file of the directory you specified , moves it to your backup directory an renames it to fit the Current Date, after that it deletes all files in the backup directory older than 356 days.

 

In the followup i tell you how to use mysqldump to dump the databases to a file!

Leave a Reply

Your email address will not be published. Required fields are marked *

18 + 13 =