1

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.

2
  • $ tar -cvf 2009-11-03_WWW.tar /web/dir/blah; :)
    – Tim
    Nov 2, 2009 at 17:41
  • It would be helpful to know what types of access you have to the web server. e.g. Do you have SSH access? Can you create and run scripts on the server? Nov 2, 2009 at 22:40

5 Answers 5

5
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.

1

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.

1

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!

0

If you have access to your Linux server, you might setup cron/crontab tasks to copy folders and database files over the network/in a safer place.

0

I use zyxBackup script that supports encryption of final backup file, so you can easily store it on public FTP/SSH server.

The backup method is easy to implement.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .