{"id":18750715,"url":"https://github.com/webiny/backupservice","last_synced_at":"2025-08-02T13:05:50.534Z","repository":{"id":62547873,"uuid":"55349912","full_name":"webiny/BackupService","owner":"webiny","description":"Simple PHP library to create and manage backups, and store them to AWS S3 bucket. It backups both files and MongoDb databases.","archived":false,"fork":false,"pushed_at":"2017-10-17T09:04:00.000Z","size":26,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-07-18T03:51:28.679Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/webiny.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-03T14:19:06.000Z","updated_at":"2023-05-21T17:35:19.000Z","dependencies_parsed_at":"2022-11-02T22:30:25.950Z","dependency_job_id":null,"html_url":"https://github.com/webiny/BackupService","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/webiny/BackupService","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webiny%2FBackupService","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webiny%2FBackupService/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webiny%2FBackupService/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webiny%2FBackupService/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webiny","download_url":"https://codeload.github.com/webiny/BackupService/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webiny%2FBackupService/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268393861,"owners_count":24243314,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-07T17:12:54.188Z","updated_at":"2025-08-02T13:05:50.475Z","avatar_url":"https://github.com/webiny.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Backup Service\n==============\n\nThis library is used to create an encrypted backup archive of one or more folders on your server and one or more MongoDb databases.\nOnce the backup archive is created, it will be stored to the defined S3 bucket. \n\nThe library automatically manages the backups on the S3 bucket and it only uploads the backup archive once. If required to keep a weekly,\nmonthly or yearly, using the S3 API backup copies are made, so we don't need to re-upload the same archive multiple times.\n \nThe backup is  a `tar gzip` archive, which is then encrypted with either `openssl` or `gpg` with the defined passphrase and only then, in this encrypted state,\nis transferred to the S3 bucket.\n  \nInstallation\n---------------------\nThe best way to install the component is using Composer.\n\n```bash\ncomposer require webiny/backup-service\n```\nFor additional versions of the package, visit the [Packagist page](https://packagist.org/packages/webiny/backup-service).\n  \n\n## Configuration\n  \nTo run the backup script, just create a small PHP script and point it to your config file:\n```php\n\u003c?php\n\nrequire_once '../vendor/autoload.php';\n\n$service = new \\Webiny\\BackupService\\Service(__DIR__.'/SampleConfig.yaml');\n$service-\u003ecreateBackup();\n\n```\n\nYou can run the script via CLI or you can configure a cron job.\n \nAs for the configuration parameters, here is an example config. \n\n```yaml\nBackupService:\n    Folders:\n        - /var/www/site1.com\n        - /var/www/site2.com\n    MongoDatabases:\n        BackupTest1:\n            Host: 127.0.0.1:27017\n            Database: BackupTest1\n            Username: Admin\n            Password: password\n        BackupTest2:\n            Host: 127.0.0.1:27017\n            Database: BackupTest2\n    Frequency: # daily backup is always on\n        - Week\n        - Month\n    TempPath: \"/tmp/backups/\"\n    Encryption:\n        Passphrase: \"test-password\"\n        Type: openssl\n    BackupStoragePath: \"/mnt/gluster/backups/\"\n    S3:\n        RemotePath: \"Backups/\"\n        AccessId: # S3 access id\n        AccessKey: # S3 access key\n        Bucket: # bucket where to store the backups\n        Region: # AWS region name where your bucket is located, eg eu-central-1\n```\n\n- `Folders`: contain one or more folders that will be added to the backup archive.\n- `MongoDatabases`: a list of mongo databases that should be exported (using mongodump) and they will also be included in the backup archive.\n- `Frequency`: by default the script keeps a 24h backup snapshot and a 48h snapshot. You can additionally add a `weekly`, `monthly` and `yearly` snapshot.\n- `TempPath`: this is a writable path on the local machine where the script will place some temporary files as well as some logs that you can later reference and see what the script has been doing.\n- `Encryption`: this are the encryption settings that will be used to encrypt the archives. Note that encryption is optional, if you don't define the key, the backup won't be encrypted. Two `types` of encryption are supported `gpg` or `openssl`.\n- `BackupStoragePath`: if you wish to store backups on the current filesystem, just set your path here. If the path is not set, the backups won't be stored locally.\n- `S3`: this is your S3 configuration. Note: make sure you get the AWS region name correctly, otherwise the script will hang on the upload process (http://docs.aws.amazon.com/general/latest/gr/rande.html). If you don't set the S3 configuration, files won't be stored to S3.\n\n## Decrypting backups\n\nDepending on the type of the decryption you used, you need to follow the following steps to decrypt your archive.\n\n### Openssl\n\n```\nopenssl bf -d \u003c backup-1day-old \u003e backup.restored.tar.gz\n```\nThis will prompt you for your passphrase. If the passphrase is correct, the archive will be decrypted and then you can extract it.\n \n### GPG\n\nGPG has a bit more complex model. Before using this encryption make sure you have generated a gpg-key and that you have imported it you the machine where you which to decrypt your backups. \n\nIf you are not sure how to do that, have a look at this StackOverflow answer: http://serverfault.com/questions/489140/what-is-a-good-solution-to-encrypt-some-files-in-unix\n\nOnce you have your backup on your machine, together with your gpg key, enter the following command in your terminal do decrypt the archive:\n\n```\ngpg --output backup.restored.tar.gz --decrypt backup-1day-old\n```\nThis will prompt you for your passphrase. If the passphrase is correct, the archive will be decrypted and then you can extract it.\n\n## Logs\n\nThe library, on each run, generates some logs in the `{TempPath}/logs` folder. You can reference those logs to see how the backup process went and was it successful or not.\n\n## License and Contributions\n\nContributing \u003e Feel free to send PRs.\n\nLicense \u003e [MIT](LICENSE)\n\n\n## Bugs and improvements\n\nJust report them under issues, or even better, send a pull request :)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebiny%2Fbackupservice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebiny%2Fbackupservice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebiny%2Fbackupservice/lists"}