Initial commit
This commit is contained in:
commit
be41a515f9
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
.DS_Store
|
||||
rclone.conf
|
25
Dockerfile
Normal file
25
Dockerfile
Normal file
@ -0,0 +1,25 @@
|
||||
FROM ubuntu:latest
|
||||
|
||||
# Install necessary packages
|
||||
RUN apt-get update && apt-get install -y \
|
||||
rclone \
|
||||
cron \
|
||||
&& apt-get clean
|
||||
|
||||
# Copy backup script into the container
|
||||
COPY backup.sh /usr/local/bin/backup.sh
|
||||
|
||||
# Set permissions for the script
|
||||
RUN chmod +x /usr/local/bin/backup.sh
|
||||
|
||||
# Add cron job for daily backups at midnight
|
||||
RUN echo "0 0 * * * /usr/local/bin/backup.sh >> /var/log/backup.log 2>&1" > /etc/cron.d/backup-cron \
|
||||
&& chmod 0644 /etc/cron.d/backup-cron \
|
||||
&& crontab /etc/cron.d/backup-cron
|
||||
|
||||
# Ensure the log file exists
|
||||
RUN touch /var/log/backup.log
|
||||
|
||||
# Start cron in the foreground to keep the container running
|
||||
CMD ["cron", "-f"]
|
||||
|
30
README.md
Normal file
30
README.md
Normal file
@ -0,0 +1,30 @@
|
||||
# Rclone Backups
|
||||
|
||||
A Docker-based system for automating encrypted backups via Rclone.
|
||||
|
||||
## Setting-Up Backups
|
||||
|
||||
Make a copy of the included `rclone.conf.template` file as `rclone.conf` and update the relevant fields. Use a long string for the encryption password.
|
||||
|
||||
Create a `docker-compose.yml` (or edit an existing) to add a block for the backup container:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
backup:
|
||||
image: wilw/rclone-backup
|
||||
volumes:
|
||||
- ./rclone.conf:/root/.config/rclone/rclone.conf
|
||||
- ./data/to/backup:/data/source
|
||||
```
|
||||
|
||||
Bring up the service with `docker compose up -d`.
|
||||
|
||||
## Restore From Backups
|
||||
|
||||
Recreate the same `rclone.conf` file as described above and install `rclone` for your system.
|
||||
|
||||
Run the following command to backup from the remote repo:
|
||||
|
||||
```bash
|
||||
rclone --config rclone.conf copy encrypted:/data ~/restore_dir
|
||||
```
|
11
backup.sh
Normal file
11
backup.sh
Normal file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set current date for incremental backup folder naming
|
||||
NOW=$(date +"%Y-%m-%d")
|
||||
|
||||
# Perform backup using Rclone sync with --backup-dir for incrementals
|
||||
rclone sync /data/source encrypted:/data \
|
||||
--backup-dir encrypted:/incrementals/$NOW \
|
||||
--log-file=/var/log/rclone.log \
|
||||
--log-level INFO
|
||||
|
11
rclone.conf.template
Normal file
11
rclone.conf.template
Normal file
@ -0,0 +1,11 @@
|
||||
[remote]
|
||||
type = s3
|
||||
provider = AWS
|
||||
access_key_id =
|
||||
secret_access_key =
|
||||
endpoint = https://gb-lon-1.linodeobjects.com
|
||||
|
||||
[encrypted]
|
||||
type = crypt
|
||||
remote = remote:BUCKET/PATH
|
||||
password =
|
Loading…
Reference in New Issue
Block a user