{ ghost } > 1 posts

How to backup your Ghost db with SCP instead of FTP.

quick tip

So you may be thinking, why would I want to do that? A: It saves a lot of time when you can just do everything right from 1 place. It's a convinience. So how does it work? ( Btw im going from CentOS to Mac. It should be pretty similar though on any *nix system.

From remote to local.

scp -P 7822 root@your_remote_ip_here:/var/www/ghost/content/data/ghost-dev.db /Users/someUser3378/Desktop/gb/ghost-dev.db  

Make sure you are not logged into the server when you run the above command.

My host, A2 Hosting requires that capital P flag there and the port since they must have it set to something other than the default. The above will move the remote ghost-dev.db file to the local ghost-dev.db on my desktop. Pretty cool huh? Next up, local to remote.

From local to remote.

scp -P 7822 ~/Desktop/localDir/someFile.txt root@your_remote_ip_here:remoteDir/  

The Database import

Before doing this, I suggest you make a backup of your production db. So this is more of a replace than an import. You just scp the db you want down and place it into your local Ghost install in the ghost/content/data directory and just replace the local db you are aiming to overwrite. I personally just preface the local db name with an underscore if it already exists. That way I can revert back if some issue occurs.

Let me know if you have any questions or tips!