{"id":18561241,"url":"https://github.com/apostrophecms/sync-content","last_synced_at":"2025-04-10T02:31:33.355Z","repository":{"id":44532928,"uuid":"272283785","full_name":"apostrophecms/sync-content","owner":"apostrophecms","description":"Back up and restore Apostrophe sites via the admin bar. Also useful for moving content between environments.","archived":false,"fork":false,"pushed_at":"2023-03-06T22:30:10.000Z","size":67,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-03T05:30:04.360Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apostrophecms.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-14T21:08:33.000Z","updated_at":"2023-05-23T13:24:50.000Z","dependencies_parsed_at":"2024-11-06T22:06:38.994Z","dependency_job_id":"d29f6828-17ee-42ec-b70e-fcca45af7c3b","html_url":"https://github.com/apostrophecms/sync-content","commit_stats":{"total_commits":23,"total_committers":3,"mean_commits":7.666666666666667,"dds":"0.13043478260869568","last_synced_commit":"92b1e31693fcff860b1b04a4ae3945a139bcb0b5"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apostrophecms%2Fsync-content","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apostrophecms%2Fsync-content/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apostrophecms%2Fsync-content/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apostrophecms%2Fsync-content/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apostrophecms","download_url":"https://codeload.github.com/apostrophecms/sync-content/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248144213,"owners_count":21054886,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T22:06:18.746Z","updated_at":"2025-04-10T02:31:33.041Z","avatar_url":"https://github.com/apostrophecms.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/apostrophecms/apostrophe\"\u003e\n    \u003c!-- TODO:  --\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/apostrophecms/apostrophe/main/logo.svg\" alt=\"ApostropheCMS logo\" width=\"80\" height=\"80\"\u003e\n  \u003c/a\u003e\n\n  \u003ch1 align=\"center\"\u003eSync Content for ApostropheCMS\u003c/h1\u003e\n\u003c/p\u003e\n\nThe 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.\n\n**Status:** ⚠️ In use, but still an alpha release. Not all planned features are implemented, but those discussed here are available.\n\n## Purpose\n\nThis 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.\n\n## Installation\n\nTo install the module, use the command line to run this command in an Apostrophe project's root directory:\n\n```\nnpm install @apostrophecms/sync-content\n```\n\n## ⚠️ Warnings\n\nThis 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.\n\n## Usage\n\nConfigure the `@apostrophecms/sync-content` module in the `app.js` file:\n\n```javascript\nrequire('apostrophe')({\n  shortName: 'my-project',\n  modules: {\n    '@apostrophecms/sync-content': {\n      // Our API key, for incoming sync requests\n      apiKey: 'choose-a-very-secure-random-key',\n      environments: {\n        staging: {\n          label: 'Staging',\n          url: 'https://mysite.staging.mycompany.com',\n          // Their API key, for outgoing sync requests\n          apiKey: 'choose-a-very-secure-random-key'  \n        }\n      }\n    }\n  }\n});\n```\n\n### Syncing via command line tasks\n\n#### Syncing from another site\n\n```bash\n# sync all content from another environment\nnode app @apostrophecms/sync-content:sync --from=staging\n\n# Pass a site's base URL and api key directly, bypassing `environments`\nnode app @apostrophecms/sync-content:sync --from=https://site.com --api-key=xyz\n\n# sync content of one piece type only, plus any related\n# documents. If other content already exists locally, purge it\nnode app @apostrophecms/sync-content:sync --from=staging --type=article\n\n# Same, but keep existing content of this type too\nnode app @apostrophecms/sync-content:sync --from=staging --type=article --keep\n\n# sync content of one piece type only, without related documents\nnode app @apostrophecms/sync-content:sync --from=staging --type=article --related=false\n\n# sync content of one piece type only, matching a query\nnode app @apostrophecms/sync-content:sync --from=staging --type=article --query=tags[]=blue\n```\n\n* You must specify `--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.\n* You may specify `--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).\n* When using `--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.**\n* By default, syncing a piece type will also sync directly related documents, such as images and other pieces referenced by joins in the document's own schema or those of its own array fields, object fields, and widgets. If you do not want this, specify `--related=false`.\n* The `--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.\n\nNote that the `--keep`, `--related` and `--query` options are only valid with `--type`. They may be combined with each other.\n\n### Syncing via the UI\n\nCurrently no UI is available, however at least some UI functionality is planned.\n\n### Security restrictions\n\nFor 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.\n\n### Additional notes\n\nSyncing a site takes time, especially if the site has media. Get a cup of coffee.\n\nIt 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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapostrophecms%2Fsync-content","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapostrophecms%2Fsync-content","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapostrophecms%2Fsync-content/lists"}