mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
Update database restore command and add example for failure case
This commit is contained in:
parent
00e264893b
commit
c5fb906d9f
2 changed files with 18 additions and 5 deletions
|
|
@ -700,7 +700,7 @@ To manually initiate a restore, execute the following command:
|
|||
docker exec -it <scheduler_container> bwcli plugin backup restore
|
||||
```
|
||||
|
||||
This command will create a temporary backup of your database and restore it to the latest backup available in the backup directory specified in the `BACKUP_DIRECTORY` setting.
|
||||
This command will create a temporary backup of your database in `/var/tmp/bunkerweb/backups` and restore your database to the latest backup available in the backup directory specified in the `BACKUP_DIRECTORY` setting.
|
||||
|
||||
You can also specify a custom backup file for the restore by providing the path to it as an argument when executing the command:
|
||||
|
||||
|
|
@ -715,3 +715,19 @@ You can also specify a custom backup file for the restore by providing the path
|
|||
```bash
|
||||
docker exec -it -v /path/to/backup/file:/path/to/backup/file <scheduler_container> bwcli plugin backup restore /path/to/backup/file
|
||||
```
|
||||
|
||||
!!! example "In case of failure"
|
||||
|
||||
Don't worry if the restore fails, you can always restore your database to the previous state by executing the command again but with the `BACKUP_DIRECTORY` setting set to `/var/tmp/bunkerweb/backups`:
|
||||
|
||||
=== "Linux"
|
||||
|
||||
```bash
|
||||
BACKUP_DIRECTORY=/var/tmp/bunkerweb/backups bwcli plugin backup restore
|
||||
```
|
||||
|
||||
=== "Docker"
|
||||
|
||||
```bash
|
||||
docker exec -it -e BACKUP_DIRECTORY=/var/tmp/bunkerweb/backups -v /var/tmp/bunkerweb/backups:/var/tmp/bunkerweb/backups <scheduler_container> bwcli plugin backup restore
|
||||
```
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ from argparse import ArgumentParser
|
|||
from datetime import datetime
|
||||
from os.path import join, sep
|
||||
from pathlib import Path
|
||||
from shutil import rmtree
|
||||
from sys import exit as sys_exit, path as sys_path
|
||||
from traceback import format_exc
|
||||
|
||||
|
|
@ -51,14 +50,12 @@ try:
|
|||
|
||||
LOGGER.info("Backing up the current database before restoring the backup ...")
|
||||
current_time = datetime.now()
|
||||
tmp_backup_dir = Path(sep, "tmp", "bunkerweb", "backup", current_time.strftime("%Y-%m-%d_%H-%M-%S"))
|
||||
tmp_backup_dir = Path(sep, "tmp", "bunkerweb", "backups")
|
||||
tmp_backup_dir.mkdir(parents=True, exist_ok=True)
|
||||
backup_database(current_time, tmp_backup_dir)
|
||||
|
||||
LOGGER.info(f"Restoring backup {backup_file} ...")
|
||||
restore_database(backup_file)
|
||||
|
||||
rmtree(tmp_backup_dir.parent, ignore_errors=True)
|
||||
except SystemExit as se:
|
||||
status = se.code
|
||||
except:
|
||||
|
|
|
|||
Loading…
Reference in a new issue