Local mirror of production blog

I’m curious if there is a way to come up with a setup that allows writing locally (specifically OSX machine) and pushing content remotely (server running Ubuntu), while having a cloud backup that also enables machine switching (using git?). Basically have the ability to write a blog post complete with media (images, video…), then push the new post to remote (production). Current idea has three instances of the blog:

  • local development version (mirror of production blog - remote server) on MacOSX.
  • Git repo of entire local dev folder synced to cloud (for backup/switching machines)
  • Production version on remote server

Some thoughts:
Git to push the whole environment including all contents to remote then extract what’s needed/changed and dump in appropriate directories.
Using the ghost Json exporter - this exports all content and creates duplicates on import so no good, then rsync to push images to remote image directory.

Not searching for a specific answer but maybe some thoughts or ideas for achieving something similar?

Hey @danhi,

Can I ask you for why you want to sync your local and remote database? I can understand why you’d want to sync the codebase of your local and remote instances, and why using git would make the most sense here, but I’m not sure I see why syncing database / content is a good idea. Is it to accurately simulate the live site on your local machine?

Synchronising databases like this can come with a fair amount of problems, many of which I’ve experienced first hand. Would creating an export from the remote server using the admin options and uploading it to your local on a periodic basis not be enough?

Hi David,

Yep the idea was to mirror the live site locally so I could work on it offline. Would the desktop app offer that? I tend to use shared media between posts at times, or often copy the structure between posts so having them accessible would be cool. Currently I use a markdown editor or Notes to write offline. Also I have my other dev projects located on my mac each with a git repo on a cloud server to sync to for backup and remote access - liked the idea of having my blog setup in a similar way.
I’ve used the exporter to sync content, then used rsync to sync the images folder. Is there a way to not have it import all posts as it creates duplicates?

When you say “work offline” do you mean coding or writing? If you mean writing then I would suggest one of our app integrations so you can write offline and then push your articles to your Ghost site:
https://ghost.org/integrations/writing/

Thanks for your suggestions David! With “work offline” I meant for writing - was looking for flexibility when writing or updating a post e.g. I could start drafting it remotely (production) using the ghost web editor, then bring it offline and work on it locally (dev), then pick it up again on remote… I began to think about this when setting up the dev environment that uses an sqlite db - thought that I could get away with setting up git to push/pull content or using rsync. Out of these integrated apps, is there one that allows to have the posts synced both ways app<>production, and not just app>production? Regarding backup I’ve been using the tools provided under Labs for contents, and Design for theme that work fantastic!

1 Like

No problem @danhi! Are you planning on going offline often? If so I would recommend sticking to writing your content in the app and then using the integration to publish it to Ghost, rather than switching between Ghost and the app. I’m not sure if the apps sync with Ghost, but even if they did it might be better for you to stick with writing inside the app to ensure a consistent writing experience :+1: