We all know that it is important to have good backups, but we also don't do that too often. So here is a little script you can dump is a cron job, and you will have your backups done automatically.
It is not that hard to make a backup, it is just one line like:tar cvfz backup.tar.gz /path/to/webroot
Why is it than that most people don't do it?
Well I don't know about you, but I figure we just don't think about it.
So what can we do about it? We automate it !
Lets start......
We all know that it is important to have good backups, but we also don't do that too often. So here is a little script you can dump is a cron job, and you will have your backups done automatically.
It is not that hard to make a backup, it is just one line like:tar cvfz backup.tar.gz /path/to/webroot
Why is it than that most people don't do it?
Well I don't know about you, but I figure we just don't think about it.
So what can we do about it? We automate it !
Lets start:
What do we need?
And especially your database backup is very important, because this is your data.
We have everything we need to know, so lets just into the code.
#!/bin/bash
tar cvfz backup_site.tar.gz /path/to/website
mysqldump -uUsername -pPassword database > backup_database.sql
Just put this in a file called backup.sh. So now we need a cronjob.
So we type the following:
crontab -e
That will open the cronjob editor. So here we will put the backup.sh file.
0 0 * * 0 backup.sh
And that way your backup is at most one week old.