Use this image to load your data from a provider into your binded folder. This folder will be used as input for restic. Restic creates a backup and upload it to your sftp host. You can configure a cron job to run the backup every day at a specific time and telegram will be used to send status reports. All of it in a container based manner.
These things are needed:
- Provider (Nextcloud, PostgreSQL, None)
- SFTP Server to store (e.g. Hetzner Storagebox)
- Docker
- a device where backup is running
1. Bind
Restic looks for a folder /source
to back up data. The behavior of this folder depends on the mode you select at the beginning of the script:
-
Bind Mounting:
- You can mount a folder from the host system into
/source
. - This approach is recommended because the data is persistent even if the container is deleted.
- You can mount a folder from the host system into
-
Internal Folder:
- If no folder is mounted, the
/source
directory exists within the container. - Warning: By default the container deletes itself after it stops. Any data stored in the container's
/source
directory will be lost.
- If no folder is mounted, the
2. Provider
The provider mode dynamically writes data into the /source
directory before restic creates a backup. This mode is useful when the data is generated by another service or application.
Providers currently supported:
- Nextcloud: Synchronizes files into
/source
. - PostgreSQL: Dumps database content into
/source
. - None: No additional data is written to
/source
.
3. Environment Variables
There is a .env
file where you can set all needed variables.
It describes every variable and provides an example value.
When used with Hetzner Storagebox, follow this guide
Currently, the private key should not have a password, it is not supported yet.
curl -O https://raw.githubusercontent.com/realAP/backup/main/run_backup.sh
curl -0 https://raw.githubusercontent.com/realAP/backup/main/.env
- make the script executable
chmod +x run_backup.sh
Fill all needed variables in the .env
file, it is provided with example values.
Just run the script ./run_backup.sh
the backup will immediately start and repeat every day at 1am (default).
For the first run, the script will initialize the restic repository.
Just work as you would do it with restic.
Example: to get the latest snapshot from your data
./run_backup.sh restore latest --target /restore
- this will restore the latest snapshot to the
/restore
folder in the container which is binded to the host
- this will restore the latest snapshot to the
as target use
/restore
to restore the data to the binded folder. For more information read the .env file example
You can use the script in two ways:
- Default is running the script without any arguments. As shown in the example above.
- e.g.
./run_backup.sh
- e.g.
- With arguments. Use the script as you would use restic. The script will run the container in which restic is started and places every argument behind it.
You have access to all the environment variables set in the
.env
file. Remember/restore
is always binded to the host. And/source
folder is binded to the host when not set tonone
../run_backup.sh snapshots
./run_backup.sh init
- and more...
Attention: the script will run the container which will be deleted after the command is executed. The data in the container is lost.
When you want to debug the container you can run the container in interactive mode.
Just run the script as follows ./run_backup.sh DEBUG
and the container will start in interactive mode.
This is just used in the development phase.
You can bind the /var/log
folder to your host to get the logs. For this set the SCRIPT_LOG_PATH
variable in the .env
file.
When the variable is not set then log files will be stored in the container.
This is just for debugging purposes.
I have used https://duplicati.com/ which i can recommend. My problem is duplicati is not supported for my hardware anymore. This is the reason for this project.
I have nextcloud hosted by hetzner (https://www.hetzner.com/storage/storage-share/) and storagebox (https://www.hetzner.com/storage/storage-box/) a sftp hosted platform. The backup should work without hetzner it just needs a nextcloud server and sftp access.
- TBD
- TBD