I'd recommend something that can do incremental backups, because that way you can go back to files that were changed several days ago. We use dirvish for this (it's available from the ubuntu repos) - basically it's a wrapper for rsync written in perl that makes it easier to setup a system to run regular incremental backups, and then expire them based on given rules.
On our system we keep backups for 7 days, but keep the first backup of the week for 1 month, and the first backup of the month for one year, so usually you can find files that were modified and deleted some time ago. For things that are small, but important, we have much longer expiry times.
As for what you should backup, imo if you have the space back up everything unless you're sure you don't need to back up. With incremental rsync backups you're only copying over the files that have changed since the last backup - I'd rather have an extra 3gb of static data belonging to the operating system on my backup drive than find it was missing one important file when I needed to recover it.
At a minimum I'd backup the entire contents of /etc/, and most of /var depending on what stuff was running on the server.
If your mysql database is fairly small then your current approach is probably acceptable, but since you need to lock the database to generate the dump this isn't practical on large databases. Because of this lots of people run a slave mysql server, which is just a read only copy of the main one on the backup server, and use this to generate backups.
The mysql documentation on how to do this is fairly good, I worked through it the first time in an evening, without much previous mysql experience.
We have our slave mysql server tied into dirvish, so each day it generates a dump of each individual database, as well as an entire copy of /var/lib/mysql (it's stops the mysql server before doing this)
According to the MariaDB website, you do not need to dump anything. Just install the new binaries and reuse existing data directory. See:
http://kb.askmonty.org/v/how-can-i-upgrade-from-mysql-to-mariadb
I would still advise to do a backup though. To be paranoid:
- tar cvfz /etc.tar.gz /etc
- tar cvfz /var/lib/mysql.backup.tar.gz /var/lib/mysql # while mysql is stopped, as Kevin mentioned
- mysqldump --all-databases
Best Answer
Here's a backup/maintenance script I use:
This script generates an individual gzipped backup of each database so that you don't have to restore the entire server's databases if there's just a problem with one DB. It also includes some mysql check sanity and finds old database backups and deletes them.
To restore, as requested:
I've had to restore a couple of times. It happens.
There's probably a more 'one line' way of doing it... but that's how it's worked for me.