Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: LAMP Backup and Restore

  1. #1
    Join Date
    Aug 2008
    Beans
    36

    Question LAMP Backup and Restore

    Hi.

    I've looked online in several places on backing up a server. And unfortunately it's just not clicking with me. It's a simple LAMP setup with a couple of vhosts. Using PHP, mySQL and wordpress.

    I would like to back everything up. The sites, the databases, and all content, config information. And then move it to another host so when it is restored on the new host. Nothing is lost. No user logins or site content.

    But I just get confused when looking this information up online in other places. I just need a quick simple solution.

    Thank you.

  2. #2
    Join Date
    Nov 2007
    Location
    Newry, Northern Ireland
    Beans
    1,258

    Re: LAMP Backup and Restore

    I'm not sure about the Wordpress thing, but for the rest, you'd want to use mysqldump to backup the database, rsync to backup the sqldump, html and php pages and Apache config files to a remote location, and then a script on the remote location to restore everything to the correct places and restore the database.

    This can all be scripted easily enough in Bash or shell of your choice and run from cron.

    Google mysqldump and rsync, or read through the man pages, if you're not sure what to do, ask and I'll try to help further.
    Can't think of anything profound or witty.
    My Blog: http://gonzothegeek.blogspot.co.uk/

  3. #3
    Join Date
    Jun 2011
    Beans
    357

    Re: LAMP Backup and Restore

    I would recommend, as the above poster stated, using mysqldump to make a snapshot of the database. Then copy the database files and the Wordpress directory tree to another location using rsync. Wordpress stores uploaded photos and such inside its directory tree instead of inside the database so it's important to back up your Wordpress files on a regular basis.

  4. #4
    Join Date
    Aug 2008
    Beans
    36

    Re: LAMP Backup and Restore

    I want to back up all databases. So I found this example online.

    Code:
    mysqldump -u root -p PASSWORD --all-databases > /path/to/dump.sql
    However, when I enter that. I get a small file created which just gives usage information.

    Usage: mysqldump [OPTIONS] database [tables]
    OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
    OR mysqldump [OPTIONS] --all-databases [OPTIONS]
    For more options, use mysqldump --help

    Not the dump of the database.

  5. #5
    Join Date
    Aug 2008
    Beans
    36

    Re: LAMP Backup and Restore

    Got the dump to work by changing it to:


    Code:
    mysqldump --user=root --password --all-databases > /path/to/all-database.sql

  6. #6
    Join Date
    Nov 2007
    Location
    Newry, Northern Ireland
    Beans
    1,258

    Re: LAMP Backup and Restore

    Quote Originally Posted by Bynw View Post
    mysqldump -u root -p PASSWORD --all-databases > /path/to/dump.sql
    I know you got it to work, but the error in the syntax above is the space between -p and PASSWORD, you should have used this:
    Code:
    mysqldump -u root -pPASSWORD --all-databases > /path/to/dump.sql
    You seem to have got the idea anyway. Have yo looked at rsync yet? Took me a while to get my head around the syntax, but it's quite easy when you practice it a bit.
    Can't think of anything profound or witty.
    My Blog: http://gonzothegeek.blogspot.co.uk/

  7. #7
    Join Date
    Jan 2010
    Location
    Portugal
    Beans
    160
    Distro
    Ubuntu Development Release

    Re: LAMP Backup and Restore

    Careful with that rsync practice. Don't do it in your production environment.
    You can sync an empty folder over the website.
    Javali
    Administração e Desenvolvimento de Sistemas Informáticos, Lda.
    Open Source Systems / SugarCRM / Alfresco / Drupal / Openbravo
    http://www.javali.pt info at javali.pt

  8. #8
    Join Date
    Nov 2007
    Location
    Newry, Northern Ireland
    Beans
    1,258

    Re: LAMP Backup and Restore

    Quote Originally Posted by HugoSerrano View Post
    Careful with that rsync practice. Don't do it in your production environment.
    You can sync an empty folder over the website.
    Good point, I should have made that clearer, thanks.
    Can't think of anything profound or witty.
    My Blog: http://gonzothegeek.blogspot.co.uk/

  9. #9
    Join Date
    Nov 2008
    Location
    Boston MetroWest
    Beans
    16,326

    Re: LAMP Backup and Restore

    I strongly recommend use the -n switch with rsync while you are troubleshooting. If you use "rsync -avn source target" you'll see a complete list of the files that would have been transferred so you can check that the paths are correct. Once you are happy with the results, remove the "n" so rsync can do its magic.
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  10. #10
    Join Date
    Aug 2008
    Beans
    36

    Re: LAMP Backup and Restore

    I did try the rsync to make copies of the files. Looks like it preserves permissions, does it preserve ownership as well?

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •