bw2io.backup
#
Module Contents#
Functions#
|
Backup the Brightway2 data directory to a .tar.gz (compressed tar archive) in a specified directory, or in the user's home directory by default. |
|
Backup project data directory to a |
|
Restore a backed up project data directory from a |
- bw2io.backup.backup_data_directory(timestamp: bool | None = True, dir_backup: str | pathlib.Path | None = None)[source]#
Backup the Brightway2 data directory to a .tar.gz (compressed tar archive) in a specified directory, or in the userâs home directory by default.
The file name is of the form âbrightway2-data-backup.{timestamp}.tar.gzâ, unless timestamp is False, in which case the file name is âbrightway2-data-backup.tar.gzâ.
Parameters#
- timestampbool, optional
If True, append a timestamp to the backup file name.
- dir_backupstr, Path, optional
Directory to backup. If None, use the userâs home directory.
Raises#
- FileNotFoundError
If the backup directory does not exist.
- PermissionError
If the backup directory is not writable.
Examples#
>>> import bw2io >>> bw2io.bw2setup() >>> bw2io.backup.backup_data_directory() Creating backup archive - this could take a few minutes...
- bw2io.backup.backup_project_directory(project: str, timestamp: bool | None = True, dir_backup: str | pathlib.Path | None = None)[source]#
Backup project data directory to a
.tar.gz
(compressed tar archive) in the userâs home directory, or a directory specified bydir_backup
.File name is of the form
brightway2-project-{project}-backup{timestamp}.tar.gz
, unlesstimestamp
is False, in which case the file name isbrightway2-project-{project}-backup.tar.gz
.Parameters#
- projectstr
Name of the project to backup.
- timestampbool, optional
If True, append a timestamp to the backup file name.
- dir_backupstr, Path, optional
Directory to backup. If None, use the default (home)).
Returns#
- project_namestr
Name of the project that was backed up.
Raises#
- ValueError
If the project does not exist.
- FileNotFoundError
If the backup directory does not exist.
- PermissionError
If the backup directory is not writable.
See Also#
bw2io.backup.restore_project_directory: To restore a project directory from a backup.
- bw2io.backup.restore_project_directory(fp: str | pathlib.Path, project_name: str | None = None, overwrite_existing: bool | None = False)[source]#
Restore a backed up project data directory from a
.tar.gz
(compressed tar archive) specified byfp
. Choose a custom name, or use the name of the project in the archive. If the project already exists, you must setoverwrite_existing
to True.Parameters#
- fpstr, Path
File path of the project to restore.
- project_namestr, optional
Name of new project to create
overwrite_existing : bool, optional
Returns#
- project_namestr, Path
Name of the project that was restored.
Raises#
- FileNotFoundError
If the file path does not exist.
- ValueError
If the project name cannot be found in the archive. If the project exists and
overwrite_existing
is False.
See Also#
bw2io.backup.backup_project_directory: To backup a project directory.