-
-
Notifications
You must be signed in to change notification settings - Fork 121
Open
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationpr welcome
Description
Description
After spending an hour trying to apply the stesp in Restore volumes from a backup, I was finally able to successfully restore from a backup and thought others might benefit from my experience.
Would be cool to see this documentation added to the section or incorporated in some way shape or form.
Proposed Example documentation:
Backup & Restore Example
In this example, we will backup a gitea service via the CLI and then perform a restoration.
Our docker-compose.yaml file written below will be located at gitea/docker-compose.yaml
Setup
docker-compose.yaml
services:
server:
image: docker.io/gitea/gitea:1.23.1-rootless
restart: always
volumes:
- data:/var/lib/gitea
- config:/etc/gitea
cap_add:
- SYS_ADMIN
- DAC_READ_SEARCH
ports:
- "3000:3000"
- "2222:2222"
volumes:
data:
config:- Save the
docker-compose.yamlfile below to a similar path above and rundocker-compose up -d - Navigate to http://localhost:3000 and run through a basic setup of gitea to ensure you have data to benchmark that backup and restoration is working correctly. If done correctly, you should be able to delete the original volumes and restore from your backups with all of your data intact.
Backup Steps
- Determine the volumes to be backed up, in this case
gitea_configandgitea_data - Determine the directory you want the backups placed in as we will need to access them later, lets say the user home directory
/home/user/Downloads - Run the manual backup process for each volume
# Backup the Config volume
docker run --rm \
-e BACKUP_FILENAME="backup-config-%Y-%m-%dT%H-%M-%S.{{ .Extension }}" \
-v gitea_config:/backup/config/gitea \
-v /home/user/Downloads:/archive \
--entrypoint backup \
offen/docker-volume-backup:v2.43.3
# Backup the Data volume
docker run --rm \
-e BACKUP_FILENAME="backup-data-%Y-%m-%dT%H-%M-%S.{{ .Extension }}" \
-v gitea_data:/backup/data/gitea \
-v /home/user/Downloads:/archive \
--entrypoint backup \
offen/docker-volume-backup:v2.43.3- You should now have 2 backup files, 1 titled
backup-data-[current timestamp].tar.gzand another one titledbackup-config-[current timestamp].tar.gz - If you can, go to another machine and download the backups to that machine. If you're operating on the same machine, you'll have to run
docker-compose downand then delete the volumes withdocker volume rm gitea_config && docker volume rm gitea_data
Restore Steps
- Now starting from a clean slate, you'll first need to create the volumes for your services before you restore the data to them. Create your volumes using your
docker-compose.yamlfile, rundocker-compose up -din thegiteadirectory - Once the volumes are created, you need to stop your services in order to restore the volumes, this can be done by running
docker-compose down - Unzip your backup data in a temporary place
tar -C /tmp -xvf backup-data-[current timestamp].tar.gz
tar -C /tmp -xvf backup-config-[current timestamp].tar.gz- Restore the data in the volumes using temporary containers. To do this, we're going to mount the data volume to a temp container, copy the unzipped files from Step 3 over, and then stop and remove the container
# Mount the data volume to a temp container, copy the unzipped files from Step 3 over, and then stop and remove the container
docker run -d --name temp_restore_container -v gitea_data:/backup_restore/data/gitea alpine && docker cp /tmp/backup/data/gitea temp_restore_container:/backup_restore/data && docker stop temp_restore_container && docker rm temp_restore_container
# Mount the config volume to a temp container, copy the unzipped files from Step 3 over, and then stop and remove the container
docker run -d --name temp_restore_container -v gitea_config:/backup_restore/config/gitea alpine && docker cp /tmp/backup/config/gitea temp_restore_container:/backup_restore/config && docker stop temp_restore_container && docker rm temp_restore_container- Run
docker-compose up -dand your volume restoration should be complete
If you go back to http://localhost:3000 you should be able to login and see your data from before
JohnGemstone
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationpr welcome