{"id":25027479,"url":"https://github.com/crazyvito11/docker-remote-backup","last_synced_at":"2026-05-10T09:34:20.627Z","repository":{"id":274872327,"uuid":"900806065","full_name":"CrazyVito11/docker-remote-backup","owner":"CrazyVito11","description":"Automatically makes periodic backups of a directory to a remote location via rclone running in Docker","archived":false,"fork":false,"pushed_at":"2025-01-29T20:45:44.000Z","size":43,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-07T09:03:05.006Z","etag":null,"topics":["automatic-backup","backup","backups","container","cron","docker","docker-compose","encrypted-backup","event-hooks","rclone","rclone-configuration"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CrazyVito11.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-09T14:01:59.000Z","updated_at":"2025-01-29T20:45:47.000Z","dependencies_parsed_at":"2025-01-29T21:40:38.950Z","dependency_job_id":null,"html_url":"https://github.com/CrazyVito11/docker-remote-backup","commit_stats":null,"previous_names":["crazyvito11/docker-remote-backup"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrazyVito11%2Fdocker-remote-backup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrazyVito11%2Fdocker-remote-backup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrazyVito11%2Fdocker-remote-backup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrazyVito11%2Fdocker-remote-backup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CrazyVito11","download_url":"https://codeload.github.com/CrazyVito11/docker-remote-backup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246351637,"owners_count":20763327,"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":["automatic-backup","backup","backups","container","cron","docker","docker-compose","encrypted-backup","event-hooks","rclone","rclone-configuration"],"created_at":"2025-02-05T19:08:22.946Z","updated_at":"2026-05-10T09:34:20.594Z","avatar_url":"https://github.com/CrazyVito11.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker Remote Backup\nAutomatically mirrors an encrypted version of a directory to a remote SFTP server via [Rclone](https://rclone.org/).\n\n\n## Setup\n### Container\n1. Copy `.env.example` and call it `.env`\n2. Fill in `.env`\n3. Create the directories beforehand with `mkdir ./logs; mkdir ./backup_dir`\n    - Note: `backup_dir` is optional in case you want to build the backup in the same directory as this container, this directory is ignored by git to prevent conflicts if you update this container.\n4. Start the Docker Compose project with `docker compose up -d --build`\n\nIt should now be ready to create backups for you!\n\n\u003e [!WARNING]\n\u003e Make sure you store the configured password and salt in a secure place like a password manager, as without those, your backups will be ***useless***!\n\n\u003e [!TIP]\n\u003e If you make a configuration change, don't forget to rebuild container again.\n\u003e Just restarting the container won't work because configuration files need to be regenerated.\n\u003e\n\u003e `docker compose down \u0026\u0026 docker compose up -d --build`\n\n\n### Remote (backup server)\nThe configuration steps that are needed will depend on what kind of machine the remote server is, but it will need to fulfill these requirements:\n\n1. Needs to run a SFTP server. _(Shell access is not required)_\n2. A backup user has been made with username + password authentication.\n3. The backup directory has nothing else inside it.\n4. The backup user has read and write access to the backup directory.\n\n\n## Creating/restoring backups\n### Create backup at remote\nA cron job has already been configured to automatically run the backup, you can control the interval using the `BACKUP_CRON_INTERVAL` setting.\n\n\u003e [!TIP]\n\u003e You can use something like [cronjob.guru](https://crontab.guru/) if you aren't familiar with the cron time format.\n\nIn case you set the interval to make backups often and it starts to overlap, it will cancel new backup requests until the previous one is done.\nThis situation will also trigger the `Lock file exists` hook.\n\n\n#### Make backup immediately\nIf you want to make the backup immediately, you can use the following command:\n```bash\ndocker compose exec docker-remote-backup bash /sync-now.sh\n```\n\n\n### Restore from remote backup\nIf you want to browse and/or download files from the remote backup, you can use the following command to start a WebDav server:\n\n```bash\ndocker compose exec docker-remote-backup rclone serve webdav remote_backup:/ --addr 127.0.0.1:8080 --read-only\n```\n\nYou should now be able to browse and download files using a webbrowser or a WebDav client _([WinSCP](https://winscp.net/eng/index.php) or [Dolphin](https://apps.kde.org/dolphin/) via `webdav://127.0.0.1:8080`)_.\n\n\u003e [!NOTE]\n\u003e For safety reasons, this WebDav server will only be reachable from the host machine (`127.0.0.1:8080`) and is _read-only_ to prevent accidental damage.\n\u003e\n\u003e If you want to make it accessible from the network while staying secure, replace `--addr 127.0.0.1:8080` with `--addr :8080 --user \"admin\" --pass \"s0mething_SECURE\"`.\n\n\u003e [!WARNING]\n\u003e If you are restoring from another machine that wasn't originally hosting this container, you will also have to make sure you use the same `.env` credentials.\n\u003e\n\u003e **NEVER** run `sync-now.sh` or any other Rclone command in this state, as you can risk damaging your remote backup!\n\n\n## Tips\n### Obfuscate passwords\nCredentials to connect or encrypt the data need to be obfuscated before they can be used.\n\n\u003e [!WARNING]\n\u003e As noted by the Rclone documentation, passwords are obfuscated to make it a bit more difficult to get, but they aren't fully protected!\n\nTo obfuscate a password, run the following command:\n\n`docker compose exec docker-remote-backup rclone obscure \"your-plain-text-password\"`\n\nThe output of this command can now be used.\n\n\n### Run script during specific events\nYou have the ability to run your own Bash scripts at certain events, this can allow you to for example send notifications in case the sync completes or fails.\n\nA couple of examples have been provided in the `hooks` directory.\n\n| Event            | Script name         | Description                                                        |\n|------------------|---------------------|--------------------------------------------------------------------|\n| Backup success   | `backup-success.sh` | Executed when the RClone command successfully finishes.            |\n| Backup failure   | `backup-failure.sh` | Executed when the RClone command ran against some kind of error.   |\n| Lock file exists | `lock-present.sh`   | Executed when the lock file exists, indicating it's still syncing. |\n\n\n### Symlinks inside backup directory\nIf you have a bunch of projects and/or you just want to store a portion of it _(data without the application itself for example)_, then you can make a backup directory that contains relative symlinks to the actual data.\n\nYou can achieve this by setting the `SOURCE_CONTEXT_DIRECTORY` to a directory that has both the backup directory and the destination of the symlinks.\nOnce you've done that, you can set `SOURCE_DIRECTORY` to the path of the backup directory, relative to the context directory.\n\nThe container will resolve the symlinks while it's creating the backup.\n\n\u003e [!WARNING]\n\u003e It's important to keep in mind that you need to have the right context configured and that you only use relative symlinks.\n\u003e\n\u003e Using full path symlinks or a wrong context will cause the container to not be able to resolve the symlinks.\n\n\u003e [!TIP]\n\u003e If your projects are spread out over multiple drives, it's recommended to just configure multiple instances of this container, one for each drive.\n\u003e\n\u003e It's not recommended to try and mount the root filesystem in the container.\n\n\n#### Example\nIn this example we want to make a backup of the `data` directory of each project in the user's home directory.\nSo we make a relative symlink to the data directory of each project, and store that inside `backup`.\n\nBecause we need to mount a directory in the container that has both the `backup` directory and the destination of the symlinks, we will configure the context directory to be `/home/example_user`.\n\nWe will then make a backup of the `/backup` directory, which will be a relative path to the context directory.\n\n```\n/home/example_user/\n├── projects/\n│   ├── project1/\n│   │   ├── README.md\n│   │   └── data/\n│   ├── project2/\n│   │   ├── README.md\n│   │   └── data/\n│   └── project3/\n│       ├── README.md\n│       └── data/\n├── backup/\n│   ├── project1 -\u003e ../projects/project1/data\n│   ├── project2 -\u003e ../projects/project2/data\n│   └── project3 -\u003e ../projects/project3/data\n```\n\nAnd inside the `.env` file, the following configuration has been used.\n\n| Configuration              | Value                |\n|----------------------------|----------------------|\n| `SOURCE_CONTEXT_DIRECTORY` | `/home/example_user` |\n| `SOURCE_DIRECTORY`         | `/backup`            |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrazyvito11%2Fdocker-remote-backup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrazyvito11%2Fdocker-remote-backup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrazyvito11%2Fdocker-remote-backup/lists"}