Giter Site home page Giter Site logo

Capistrano SQL backup and sync about bedrock HOT 8 CLOSED

roots avatar roots commented on July 18, 2024
Capistrano SQL backup and sync

from bedrock.

Comments (8)

swalkinshaw avatar swalkinshaw commented on July 18, 2024

Glad to hear you're liking Bedrock :)

  1. I doubt we'd ever have this feature included by default. I understand the use case but at first thought it seems like it would be best in an extension.
  2. This is something that would probably also be an extension (separate Gem) but maybe included by default.

I think this would actually be a fairly simple wrapper using WP-CLI. No point in duplicating a tool that already does it well. It has import and export (http://wp-cli.org/commands/db/) and search-replace too (http://wp-cli.org/commands/search-replace/).

from bedrock.

heyfletch avatar heyfletch commented on July 18, 2024

In addition to wp-cli for sql tasks, I've come across syncdb. Looks promising.

from bedrock.

treb0r avatar treb0r commented on July 18, 2024

IMHO WP Migrate Pro is the only way to fly. It handles find and replace, remembers profiles and also syncs media files. I have been using it in tandem with bedrock and now I realise that I want to handle the database sync separately from Capistrano just to have flexibility.

https://deliciousbrains.com/wp-migrate-db-pro/

from bedrock.

leotulipan avatar leotulipan commented on July 18, 2024

Wouldn't using a plugin like Migrate Pro violate one of the 12 factor rules (namely "4 backing services" http://12factor.net/backing-services) ?

IMO using Capistrano + WP-CLI (and mabye syncdb) for snapshoting, updating and synching is the cleaner way.

from bedrock.

treb0r avatar treb0r commented on July 18, 2024

It may possibly be 'cleaner' in some sense but WP Migrate Pro works well, is here now, requires zero configuration and is a joy to use.

I find that separating the db sync from the rest of the deploy brings benefits in added flexibility. And having the media files synced with the DB saves a lot of time.

from bedrock.

lavmeiker avatar lavmeiker commented on July 18, 2024

Hi guys! Here's one approach to the problem solution. This rubygem that will add db pull and push using WP-CLI. https://github.com/lavmeiker/capistrano-wpcli

This is my first public release so I'd appreciate some feedback on this one! 😃

Hope you find it useful.

from bedrock.

swalkinshaw avatar swalkinshaw commented on July 18, 2024

Just closing this as it's discussion. Can be carried on here http://discourse.roots.io/.

from bedrock.

tommymarshall avatar tommymarshall commented on July 18, 2024

In case anyone else was looking at this, I added db backups when pushing/puling a DB. Added to the end of config/deploy.rb:

time             = Time.new
backup_timestamp = time.strftime("%Y%m%d%H%M")

set :db_backup_file_name,        -> {"wpcli_db_backup.#{backup_timestamp}.sql.gz"}
set :local_db_folder_path,       -> {"./db_backups"}
set :local_db_folder_file_path,  -> {"./db_backups/#{fetch(:db_backup_file_name)}"}
set :remote_db_folder_path,      -> {"#{fetch(:deploy_to)}/db_backups"}
set :remote_db_folder_file_path, -> {"#{fetch(:deploy_to)}/db_backups/#{fetch(:db_backup_file_name)}"}

before 'wpcli:db:pull', :backup_local_db do
  run_locally do
    execute :mkdir, "-p", fetch(:local_db_folder_path)
    execute :wp, :db, :export, "- |", :gzip, ">", fetch(:local_db_folder_file_path)
  end
end

before 'wpcli:db:push', :backup_remote_db do
  on roles(:web) do
    within release_path do
      execute :mkdir, "-p", fetch(:remote_db_folder_path)
      execute :wp, :db, :export, "- |", :gzip, ">", fetch(:remote_db_folder_file_path)
    end
  end
end

And then just .gitignore the db_backups directory.

from bedrock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.