Jump to content

How to make backup of database?


haha
 Share

Recommended Posts

The Site Profile Exporter will backup the database:

http://modules.processwire.com/modules/process-export-profile/

It will also include all files and templates so it may be more than what you are looking for.

If you want to backup just the database, there are a lot of non PW specific tools for this. If you are comfortable with the command line look into mysqldump which you can trigger with a cronjob and automatically copy to a remote server using rsync. The site profile exporter uses mysqldump for the DB part of the export.

If you are after a more automated and user friendly approach with a graphical user interface, something like:

http://sourceforge.net/projects/automysqlbackup/ works well, but there are lots of other options if you google: https://www.google.com/search?q=mysql+backup+tool

Perhaps it might be a worthwhile addition to PW to have a stripped down version of the site profile exporter that just exports the database. This could be run with the lazycron module.

  • Like 2
Link to comment
Share on other sites

Hey I mean I had installed PW to a database with exist table.

as i didn't know which table belongs to PW ,so there I got this problem , I don't know how to backup my database (there is not a prefix of database table)

Link to comment
Share on other sites

Hey I mean I had installed PW to a database with exist table.

as i didn't know which table belongs to PW ,so there I got this problem , I don't know how to backup my database (there is not a prefix of database table)

:wacko: Not a good decission.

Do you know all other tablenames (all none-PW-tables)? If yes, then take all but not this. If no, you may look for all tables beginning with field_

and minimum the tables:

  • pages
  • pages_access
  • pages_parents
  • pages_sortfields
  • templates
  • modules
  • fields
  • fieldgroups
  • fieldgroups_fields

But there may be more, depending of your installed thirdparty-modules!

For example I have a table session_login_throttle and a table process_forgot_password in one DB.

EDIT:

and for those who are looking for backup tools, we have had already some threads/post about that:

Edited by horst
  • Like 4
Link to comment
Share on other sites

  • 3 years later...
  • 2 weeks later...
  • 10 months later...

Another year has passed...

I was looking for a way to include database backup in my deployment process. I did not want to use some external secrets storage yet, so looked for a way to use db credentials already present in PW config. So I wrote a simple script, which I put in the project repo and call from cli during the deployment process like this:

php -f backup.php

For the sake of simplicity backup.php is in the web root. Here are its contents:

<?php
// backup.php

include("index.php");
$backup = $database->backups();
$file = $backup->backup();
    if($file) {
        echo "Backed up to: $file";
    } else {
        echo "Backup failed: " . implode("<br>", $backup->errors());
 }

The full docs on how to customize it as you need should be here, but are now missing for some reason. One can still get them from the source code anyway)


P.S. I am looking for a way to do it with a simple one-liner in cli to get rid of the backup.php, but not sure it is possible with php an easy way. Any advice appreciated!

P.P.S. I knew I could do it, because @adrian done it in his wonderful Admin Actions module. Go read its code for inspiration and for education, if you are not a PW guru yet.

  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...