Look into using rsync
to perform the actual backup to your other server:
man rsync
You will need to know exactly what data you would like to backup, though. Just from the list of programs (if you are using the vanilla directories), you will want to at least backup:
- /var/lib/apache2
- /var/log/apache2
- /var/www
- /etc/apache2
- /var/lib/mysql
For scheduling the backup process, you can look into crontab
:
man crontab
Tips:
- Try to isolate the backup process to a specific user, then give it read access to the backup directories. I would highly recommend not using the
root
user to backup your data.
- Make sure that your backup script is executable (
chmod +x /my/backupscript
)
rsync
runs over SSH, so whatever is initiating the backup will need SSH access (man ssh-keygen
).
- Depending on what kind of data you are hosting, you will want to make sure and stop all processes that are using the backup directories. I would definitely recommend stopping MySQL at a minimum (
service mysqld stop
).
- It's more efficient to make a local, compressed (
man tar
) backup of the data (for example, to /backups/mydata_$(date +%s).tgz
), then rsync
the local backup to your other server. Actively rsync
ing the actual directories could lead to extended downtime on your db as your dataset grows.