backup-server/README.md

78 lines
2.4 KiB
Markdown
Raw Normal View History

2019-05-03 16:30:06 +00:00
# backup-server
2019-05-04 02:18:34 +00:00
Docker based ssh backup host with `borg` and `restic` installed. Can be effectively used for as a backup repository and a tool to backup containers.
Development occurs at [https://git.andr3w.net/amd/backup-server](https://git.andr3w.net/amd/backup-server)
2019-05-04 02:18:34 +00:00
## Run a backup host and backup a client with `borg`
2019-06-30 20:34:14 +00:00
Start a container on the backup host with this command:
2019-05-04 02:18:34 +00:00
docker run -d \
--restart always \
2019-08-26 18:59:35 +00:00
--publish 2222:22 \
2019-05-04 02:18:34 +00:00
--volume /mnt/backup:/bkup \
--name backup \
amdavidson/backup:latest
Add your ssh key to the host:
2019-05-04 02:18:34 +00:00
docker cp id_rsa.pub backup:/bkup/.ssh/authorized_keys
docker run --volumes-from backup amdavidson/backup-server chown 1111:1111 /bkup/.ssh/authorized_keys
2019-06-30 20:34:14 +00:00
On the machine to be backed up run this to create a repository for backups:
2019-05-04 02:18:34 +00:00
borg init backup:/bkup/client-name
Periodically run a backup with a command similar to this:
2019-05-04 02:18:34 +00:00
borg create --stats --verbose backup:/bkup/client-name::$(date '+%s') ~/
## Backup a container remotely with `restic`
2019-05-04 02:18:34 +00:00
2019-06-30 20:34:14 +00:00
On the machine with the container to be backed up, create a repository for backups:
2019-05-04 02:18:34 +00:00
docker run \
--rm \
--volumes-from backup \
--env RESTIC_PASSWORD=secretpw \
--env AWS_ACCESS_KEY_ID=$ACCESS_KEY \
--env AWS_SECRET_ACCESS_KEY=$SECRET_KEY \
2019-05-04 02:18:34 +00:00
amdavidson/backup-server \
restic -r s3:s3.wasabisys.com/other-container init
Perodically run a backup with a command similar to this:
2019-05-04 02:18:34 +00:00
docker run \
--rm \
--volumes-from backup \
--volumes-from other-container:ro \
--env RESTIC_PASSWORD=secretpw \
--env AWS_ACCESS_KEY_ID=$ACCESS_KEY \
--env AWS_SECRET_ACCESS_KEY=$SECRET_KEY \
2019-05-04 02:18:34 +00:00
amdavidson/backup-server \
restic -r s3:s3.wasabisys.com/other-container backup /data
## Backup a container locally with `borg`
2019-05-04 02:18:34 +00:00
2019-08-26 18:59:35 +00:00
On the machine with a container to be backed up, create a repository for backups (entering the encryption password when requested):
2019-05-04 02:18:34 +00:00
docker run \
2019-08-26 18:59:35 +00:00
--rm -it \
2019-05-04 02:18:34 +00:00
--volumes-from backup \
amdavidson/backup-server \
borg init /bkup/other-container
Periodically run a backup with a command similar to this:
2019-05-04 02:18:34 +00:00
docker run \
--rm \
--volumes-from backup \
--volumes-from other-container:ro \
2019-08-26 18:59:35 +00:00
--env BORG_PASSPHRASE="mySecr3t" \
2019-05-04 02:18:34 +00:00
amdavidson/backup-server \
borg create --verbose --stats /bkup/other-container::$(date '+%s') /data