Apostrophe Sync
An ApostropheCMS companion script for syncing MongoDB database collections and /uploads
folder contents between local and remote environments.
Prerequisites:
bash
rsync
jq
-
mongodump
&mongorestore
- they can be installed as a part of the MongoDB Database Tools - correctly set environmental variables inside the
aposync.config.js
in order to connect via SSH client
How to use:
- Add the package with your favourite package manager to your project e.g.
npm install @bohemicastudio/apostrophe-sync
- Run
aposync init
to create the configuration fileaposync.config.js
in the root folder of your project and set the necessary variables inside. - Run
aposync
command in your terminal to access an action overview menu. - Input the numeric code inside the square brackets to run the desired action.
- If you remember the code number you can enter it after the command e.g.
aposync 101
oraposync 101 -y
to skip the confirmation.
- If you remember the code number you can enter it after the command e.g.
- Now relax and let the script do the work for you.
Configuration:
aposync.sh
- the main script file that serves as a crossroad for executing the subscripts:
-
db-up.sh
- transfers MongoDB collection from a local to a remote environment -
db-down.sh
- transfers MongoDB collection from a remote to local environment -
files-up.sh
- transfers local "uploads" files to a remote environment-
-d
,--dry
- only executes a test run and lists files missing in the remote folder -
-f
,--force
- deletes remote files that don't exist locally
-
-
files-down.sh
- transfers remote "uploads" files to a local environment-
-d
,--dry
- only executes a test run and lists files missing in the local folder
-
-
restore-local.sh
- restores local MongoDB collection from a chosen local backup/dump file -
restore-remote.sh
- restores remote MongoDB collection from a chosen remote backup/dump file -
list-local.sh
- lists all local MongoDB backup files -
list-remote.sh
- lists all remote MongoDB backup files -
backup-local.sh
- creates a MongoDB backup file locally -
backup-remote.sh
- creates a MongoDB backup file remotely