Gathering detailed insights and metrics for @apostrophecms/sync-content
Gathering detailed insights and metrics for @apostrophecms/sync-content
Gathering detailed insights and metrics for @apostrophecms/sync-content
Gathering detailed insights and metrics for @apostrophecms/sync-content
Back up and restore Apostrophe sites via the admin bar. Also useful for moving content between environments.
npm install @apostrophecms/sync-content
Typescript
Module System
Node Version
NPM Version
67.7
Supply Chain
96.9
Quality
81.8
Maintenance
100
Vulnerability
99.6
License
JavaScript (100%)
Total Downloads
1,735
Last Day
5
Last Week
6
Last Month
19
Last Year
387
MIT License
4 Stars
26 Commits
1 Forks
3 Watchers
4 Branches
5 Contributors
Updated on May 23, 2023
Minified
Minified + Gzipped
Latest Version
1.0.0-alpha.3
Package Id
@apostrophecms/sync-content@1.0.0-alpha.3
Unpacked Size
32.25 kB
Size
9.80 kB
File Count
8
NPM Version
8.19.2
Node Version
16.15.0
Published on
Mar 06, 2023
Cumulative downloads
Total Downloads
Last Day
400%
5
Compared to previous day
Last Week
100%
6
Compared to previous week
Last Month
-38.7%
19
Compared to previous month
Last Year
-10.6%
387
Compared to previous year
6
The Sync Content module allows syncing ApostropheCMS site content between different server environments, without the need for direct access to remote databases, directories, S3 buckets, etc.
Status: ⚠️ In use, but still an alpha release. Not all planned features are implemented, but those discussed here are available.
This module is useful when migrating content between development, staging and production environments without direct access to the underlying database and media storage. It is also useful when migrating between projects, however bear in mind that the new project must have the same doc and widget types available with the same fields in order to function properly.
To install the module, use the command line to run this command in an Apostrophe project's root directory:
npm install @apostrophecms/sync-content
This tool makes big changes to your database. There are no confirmation prompts in the current command line interface. Syncing "from" staging or production to your local development environment is generally safe, but take care to think about what you are doing.
Configure the @apostrophecms/sync-content
module in the app.js
file:
1require('apostrophe')({ 2 shortName: 'my-project', 3 modules: { 4 '@apostrophecms/sync-content': { 5 // Our API key, for incoming sync requests 6 apiKey: 'choose-a-very-secure-random-key', 7 environments: { 8 staging: { 9 label: 'Staging', 10 url: 'https://mysite.staging.mycompany.com', 11 // Their API key, for outgoing sync requests 12 apiKey: 'choose-a-very-secure-random-key' 13 } 14 } 15 } 16 } 17});
1# sync all content from another environment 2node app @apostrophecms/sync-content:sync --from=staging 3 4# Pass a site's base URL and api key directly, bypassing `environments` 5node app @apostrophecms/sync-content:sync --from=https://site.com --api-key=xyz 6 7# sync content of one piece type only, plus any related 8# documents. If other content already exists locally, purge it 9node app @apostrophecms/sync-content:sync --from=staging --type=article 10 11# Same, but keep existing content of this type too 12node app @apostrophecms/sync-content:sync --from=staging --type=article --keep 13 14# sync content of one piece type only, without related documents 15node app @apostrophecms/sync-content:sync --from=staging --type=article --related=false 16 17# sync content of one piece type only, matching a query 18node app @apostrophecms/sync-content:sync --from=staging --type=article --query=tags[]=blue
--from
to specify the environment to sync with, as seen in your configuration above, where staging
is an example. You can also specify the base URL of the other environment directly for --from
, in which case you must pass --api-key
as well. At a later date support for --to
may also be added.--type=typename
to specify one content type only. This must be a piece type, and must match the name
option of the type (not the module name, unless they are the same).--type
, you may also specify --keep
to keep preexisting pieces whose _id
does not appear in the synced content. For data integrity reasons, this is not available when syncing an entire site.--related=false
.--query
option is best used by observing the query string while on a pieces page with various filters applied. Any valid Apostrophe cursor filter may be used.Note that the --keep
, --related
and --query
options are only valid with --type
. They may be combined with each other.
Currently no UI is available, however at least some UI functionality is planned.
For security reasons, and to avoid chicken and egg problems when using the UI, users and groups are not synced. You will have the same users and groups as before the sync operation.
Syncing a site takes time, especially if the site has media. Get a cup of coffee.
It is not uncommon to see quite a few warnings about missing attachments at the end, particularly if another image size was added to the project without running the apostrophe-attachments:rescale
task.
No vulnerabilities found.
No security vulnerabilities found.