Jump to content

Seeking a bash/script to quickly backup InnoDB database so I can keep under git


OrganizedFellow
 Share

Recommended Posts

I have an old script that no longer works.

My previous workflow was: prior to running git push, I would run a git alias that did a quick backup of the project, save with timestamp-filename, and then after successfully backing up, it would continue with git push to remote.

That script is old and not working anymore. Rather than fix the script, I am wondering if anyone here has one they might share?!

Link to comment
Share on other sites

Sorry, I have no regular script for this but mysqldump is good for creating a db.sql file that you can then store under git.  You may be able to use something like a pre-commit git hook to automate the dump as part of your git workflow.

https://github.com/DavidJRobertson/ProcessWire-ScheduleCloudBackups might be useful for live site backups - I've not used it myself. Wasabi is S3 compatible and much cheaper.

Link to comment
Share on other sites

See here: https://github.com/BernhardBaumrock/tabulator.test/blob/837d509f1ef6816fe3629c163bd66d53c5e39209/site/ready.php#L31-L73

That's exactly doing what you are looking for but also creates a ZIP of the sql (which reduces size drastically). It also comes with a restore script: https://github.com/BernhardBaumrock/tabulator.test/blob/master/site/assets/mysqldump/restore.php

This is the first time I'm using it, so it's not well tested and some parts are hardcoded (eg tabulator.sql / tabulator.zip). But it should get you going. I created this because the pw internal dump takes ages to restore ( for @dragan it took several hours? ).

My workflow:

  • logout
  • commit changes
  • push changes
  • Like 4
Link to comment
Share on other sites

I'm using this: https://github.com/dragan1700/site-backup

One script creates a ZIP of the entire site, the other creates a DB-dump. They can be also used with Cron, if you just put in the shebang (may vary in your server setup). Since normally I'm not working with huge databases, I didn't do an option to zip the .sql as well, but I might add that later if the need arises.

  • Like 4
  • Thanks 1
Link to comment
Share on other sites

Well, I had it for ages, but only today made a Github repo and thought I could just as well share it.

And yes, it's similar because we apparently use the same core class ifsnop :-)

It's especially useful if you have to work on a site where you can't quickly create a files-backup as ZIP, nor un-zip easily via control panel (which is standard in Plesk et al). Or if you can't run system commands, because the hosting company doesn't allow it. 

On some sites, I have it running with a hook and/or PW lazycron. And before any major changes (dev/prod), I just trigger it manually.

  • Like 2
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...