Jump to content

How to make backup of database?

Recommended Posts

The Site Profile Exporter will backup the database:


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

Share this post

Link to post
Share on other sites

Please note that the Site Profile Exporter doesn't export users and the access control settings.

  • Like 2

Share this post

Link to post
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)

Share this post

Link to post
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.


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

Edited by horst
  • Like 4

Share this post

Link to post
Share on other sites
On 2017-5-26 at 11:58 AM, Ivan Gretsky said:

Years later we have more options)

There is a special module by @ryan for that now.

How did I miss this? Here's me logging into cpanel > phpmyadmin > export DB > unchecking cache data... blaaaaaaah! Must give this a try.

Thanks @Ivan Gretsky.

  • Like 1

Share this post

Link to post
Share on other sites

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:

// backup.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

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By DooM
      Hello guys,
      I'm trying to figure out how to sync fields and templates between staging and production environments.
      I've found Migrations module by Lostkobrakai, but with use of it all the fields and templates must be created by API, which is kind of uncomfortable.
      I also tried ProcessDatabaseBackups module which can export only certain tables, but I don't think it's the best practice to do that.
      How do you guys solve this problem? It's very annoying to setup everything three times (dev, staging, production).
      Thanks a lot :)
    • By iipa
      Hi everybody!
      I have been reading about Multisite, but it kinda bugs me that every topic talks about having both admin and database same for multiple sites.
      I have a project where customer tests it by adding content to the site, while I still need to do some changes here and there in code, maybe some in database. If something crashes for a while, customer can't keep testing, which is a bit problematic.
      Is there any way that I could have two separate versions of one site ("production" and development) that share the same database, but are otherwise independent? Just the thought of having to migrate database every time I want to show client something new gives me anxiety 😁
    • By Falk
      After temporarily using Module Image Extra, which I completely removed, I had some troubles with my imagefield (unused table columns).
      So I just imported a previous version of this column via PHPmyAdmin, which worked pretty well.
      Anyways, in Processwire Backend all image tags are gone, although they are OK in the database.
      Other image related things work (thumbnail, title etc are OK).
      Is there any way to recreate all the images or something? Or may this be an cache-related issue?
      Thanks in advance 😃
    • By anttila
      We have many booking calendars made with ProcessWire (own databases) and I want to do a web app (SQL) which allows user to log in. First, the user chooses the right calendar and then (s)he have to log in. The user can be from any of those calendars and the app is not running on ProcessWire (it can if necessary). So if there any way to make sure that the user has rights to the calendar (s)he tries to log in and if the password is correct.
      Is there any better way to do this? I could also use PIN codes or something, but those need to be encrypted too.
      Multiple ProcessWires A lot of users per ProcessWire Everyone can log in to the web app (when using right calendar)
    • By nuel
      Hi there
      Basically I want to call code within a ProcessWire page that isn't used as a template. Example: www.mypwpage.com/myphpfile.php
      I have a working PW Website with a couple of pages like /artists, /releases, /videos etc. Now I need a page /download without any editable fields in the backend, just calling some PHP code (that was coded by another guy) containing a form that checks unique download-codes in a second database and starts the download of the desired file. The script is working fine right now as part of a static website, but since I built PW behind the site, this independent «Download Section» of the page doesn't work anymore.
      Right now I have the main file download.php as a page template on a newly created empty page called /download, so until now the form is working (wow). After sending the form containing the download-code, the file check_code.php in a subfolder /site/templates/download is called and that's where I get an error.
      Any help?
  • Create New...