Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

My hosting company may cut me off. Any ideas on what files I should back up?

I am running RedHat 4.1.

How would I save my current PHP set up? Can I just save the .so files?

MySQL - is backing up the data directory and my.cnf enough?

Apache - httpd.conf, html folders, sure, but anything else?

share|improve this question

4 Answers 4

In order of the three programs you listed:

  • Unless you modified some of your PHP configuration, you probably don't need to back up anything as you'll be running on default settings. However, the PHP configuration is usually located in up to four places: php.ini, php-cli.ini, and php/extensions.ini, and php/. These locations are usually in /etc, but they might be in /usr/local/etc instead.
  • You need to dump the data from MySQL. Copying the directory will generally require at least a 'repair' operation later, and will outright fail enough of the time that you shouldn't even bother trying it. Use mysqldump, like this: mysqldump -u username -a -p | gzip -c > mysqlbackup.sql.gz. This will prompt for "username"'s password to MySQL, and dump all accessible databases for that user (if you do it as the root MySQL user, that will be everything).
  • Everything under wherever the apache configuration is stored is generally best. That's usually httpd/, apache/ or apache2/ in /etc or /usr/local/etc. Note that sometimes these folders contain a symlink to your logs directory, and if you copy that you might end up with more than you wanted!
  • Your actual web content (.html files, .php files, etc). These are wherever you put them!
share|improve this answer
    
Don't forget about the /home/* directories if you you have active users –  Jacco Jun 3 '09 at 10:10
    
Getting a list of the current software versions on the system maybe useful if you run into problems later, especially if you run custom code. –  skitzot33 Jun 3 '09 at 12:29

Saving your .so files (dynamically linked libraries) would require you to restore them to a system running exactly the same architecture and exactly the same version of all dependencies with exactly the same version of compiler/linker. In one word: failure. In general, the best approach to this is having an installation documentation or script which can be used to reproduce the current set up (mutatis mutandum) on the new environment.

For mysql: dump data and schema structure, for web content, backup the files and server configuration.

share|improve this answer
  • /etc
  • /var/www

Do a mysqldump of all databases into a dated file, like servername-alldb-20090603.sql

You probably shouldn't worry about your php.conf file unless you've got special things setup for some software you're running.

share|improve this answer

If it's a VPS to which you have full access, it's good idea to backup /etc, /home, /var, /usr/local directories, and anything else that you had to change by hand. Other directories, like /usr are handled by the system's package manager and you don't need to have backups for them - when you will configure new machines, system will install all neccessary files for you.

*.so files are shared libraries, they are created at compilation time, and unless you changed the sources, you don't need to backup them. PHP configuration can be found in /etc/php?/* directories and files (on Debian, on Red Hat it should be in a similar place).

As for MySQL, it's good to make a text dump of the database using mysqldump - it will be easier for you to restore the databases in different MySQL instance which may by a different version, incompatible with files from the data/ directory.

Apache configuration should be kept within /etc directory, or within virtual hosts directories, which you should also backup.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.