From b995e0340fb3a262cb194c43c896f6cd447eb8d3 Mon Sep 17 00:00:00 2001 From: Wendy Wang Date: Mon, 20 Jan 2025 17:06:49 +0100 Subject: [PATCH] Updated README per comments --- .../contrib/utils/database_backup/README.md | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/evennia/contrib/utils/database_backup/README.md b/evennia/contrib/utils/database_backup/README.md index 3e8e5a7882..be2122a355 100644 --- a/evennia/contrib/utils/database_backup/README.md +++ b/evennia/contrib/utils/database_backup/README.md @@ -10,7 +10,7 @@ Currently, the sqlite3 (the evennia default) and postgresql databases are suppor ## Installation -This utility adds the `backup` command. Import the module into your commands and add it to your command set to make it available. +This utility adds the `backup` command. The `backup` command can be used to set up a scheduled backup script, or trigger the script to run immediately. The backup script makes a backup of your game world. Import the module into your commands and add it to your command set to make it available. In `mygame/commands/default_cmdsets.py`: @@ -28,6 +28,21 @@ class CharacterCmdset(default_cmds.Character_CmdSet): Then `reload` to make the `backup` command available. +If you prefer to run the script without the `backup` command, you can manage it as a global script in your settings: + +```python +# in mygame/server/conf/settings.py + +GLOBAL_SCRIPTS = { + "backupscript": { + "typeclass": "evennia.contrib.utils.database_backup.DatabaseBackupScript", + "repeats": -1, + "interval": 86400, + "desc": "Database backup script" + }, +} +``` + ## Permissions By default, the backup command is only available to those with Developer permissions and higher. You can change this by overriding the command and setting its locks from "cmd:pperm(Developer)" to the lock of your choice. @@ -43,16 +58,16 @@ Remember to `evennia stop` before restoring your db. ### Restoring sqlite3 (.db3) * Copy the database backup you want to restore from back into the `server/` directory -* Rename the database backup to `evennia.db3` if you have not modified `settings.DATABASES`, otherwise whatever name is in your `settings.DATABASES` dictionary. +* By default (unless you changed the name of the file in `settings DATABASES`), the game data is expected to be located in the sqlite3 file `mygame/server/evennia.db3`. Copy your backup file over this file to recover your backup. ### Restoring postgres (.sql) * Prepare the following variables ``` -export DB_USER=db_user from your settings.DATABASES -export DB_NAME=db_name from your settings.DATABASES -export BACKUP_FILE=the path to the backup file you are restoring from -export PGPASSWORD=your db password +export DB_USER=db_user # db_user from your settings.DATABASES +export DB_NAME=db_name # db_name from your settings.DATABASES +export BACKUP_FILE=backup_file_path # the path to the backup file you are restoring from +export PGPASSWORD=db_password # the password to your db If you prefer not to export your password to an env variable, you can enter it when prompted instead. ```