fix: backup and restore

create backup dir in worker images
set ownership and mount volume for backups
update readme about restore backup
This commit is contained in:
Revant Nandgaonkar
2020-03-27 16:41:32 +05:30
parent 4e7b7690ee
commit 2422fbad26
4 changed files with 51 additions and 10 deletions

View File

@@ -236,12 +236,15 @@ Environment Variables
- `BACKUP_LIMIT`, Optionally set this to limit number of backups in bucket directory. Defaults to 3.
```sh
docker exec -it \
docker run \
-e "BUCKET_NAME=backups" \
-e "ACCESS_KEY_ID=access_id_from_provider" \
-e "SECRET_ACCESS_KEY=secret_access_from_provider" \
-e "ENDPOINT_URL=https://region.storage-provider.com" \
-e "BUCKET_DIR=frappe-bench-v12" \
-v ./installation/sites:/home/frappe/frappe-bench/sites \
--network <project-name>_default \
frappe/frappe-worker:v12 push-backup
```
Note:
@@ -278,6 +281,44 @@ docker exec -it \
<project-name>_erpnext-python_1 docker-entrypoint.sh migrate
```
#### Restore backups
Environment Variables
- `MYSQL_ROOT_PASSWORD`, Required to restore mariadb backups.
- `BUCKET_NAME`, Required to set bucket created on S3 compatible storage.
- `ACCESS_KEY_ID`, Required to set access key.
- `SECRET_ACCESS_KEY`, Required to set secret access key.
- `ENDPOINT_URL`, Required to set URL of S3 compatible storage.
- `BUCKET_DIR`, Required to set directory in bucket where sites from this deployment will be backed up.
```sh
docker run \
-e "MYSQL_ROOT_PASSWORD=admin" \
-e "BUCKET_NAME=backups" \
-e "ACCESS_KEY_ID=access_id_from_provider" \
-e "SECRET_ACCESS_KEY=secret_access_from_provider" \
-e "ENDPOINT_URL=https://region.storage-provider.com" \
-e "BUCKET_DIR=frappe-bench-v12" \
-v ./installation/sites:/home/frappe/frappe-bench/sites \
-v ./backups:/home/frappe/backups \
--network <project-name>_default \
frappe/frappe-worker:v12 restore-backup
```
Note:
- Volume must be mounted at location `/home/frappe/backups` for restoring sites
- If no backup files are found in volume, it will use s3 credentials to pull backups
- Backup structure for mounted volume or downloaded from s3:
- /home/frappe/backups
- site1.domain.com
- 20200420_162000
- 20200420_162000-site1_domain_com-*
- site2.domain.com
- 20200420_162000
- 20200420_162000-site2_domain_com-*
### Custom apps
To add your own Frappe/ERPNext apps to the image, we'll need to create a custom image with the help of a unique wrapper script