How do you backup your websites?
I was curious as to how people normally back up their websites. I normally drag and drop from FTP and use phpmyadmin to download a copy of my databases. I'm sure there's a way where you write a script and have it back up your stuff automatically or upon click, how do people do that? Is it possible to use php to back up stuff?
I have SSH access too.
ssh ${USER}@${SERVER} "tar czpf - /path/to/htdocs" > backup_${DATE}.tar.gz
It gets a bit more difficult once databases are involved, but not too much so. (Dump the database to file while keeping an eye on charset encoding, then include the dump into the tarball.)
KISS concept.
You can use a separate file server and cron to dump the database using php / sql through bash then ftp it to another server, on a timed schedule.
Good things to use: mysql dump, cron, sftp, ssh.
I use mysqldump and tar. But the devil is in the details, and it really depends on the specifics of your system. DO make sure you know your encoding: this should be (but isn't always) consistent between your CMS software (e.g. Expression Engine, WordPress, Joomla, whatever), your framework (e.g. PHP), your database (e.g. mysql), and this includes, the tables' individual collation settings, AND the settings of the client, (in this case, mysqldump; to be sure, use the command-line option --default-character-set=utf8, or whatever your encoding is). If your data is encoded one way, and you backup to another encoding, and restore that backup, your data may be subtly corrupted. Everything from; funny characters showing up for double-quotes, hyphens, foreign characters, umlauts and accents, etc - to the worst-case, text strings in serialized fields come back with bad lengths, causing php's unserialize() to fail.
A quicker way of saying all this: TEST your backups! Frequently!