Name | backup-pro JSON |
Version |
1.0.1
JSON |
| download |
home_page | |
Summary | A comprehensive backup tool that makes the life easier when backing up/restoring configurations, files, packages of the system. |
upload_time | 2023-08-19 14:17:23 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.10 |
license | MIT License Copyright (c) 2023 Halit Şimşek Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
apt
archive
backup
backup-pro
cli
configuration
diff
flatpak
gsettings
package
pro
recovery
restore
scan
snap
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Backup Pro
A comprehensive backup tool that makes the life easier when backing up/restoring configurations, files, packages of the system.
Some features:
* Tracking installed packages (e.g. `apt` packages)
* Tracking configurations (e.g. `gsettings`)
* Tracking paths on the filesystem
* Capability of excluding specified subdirectories
* Environment variable support on tracked paths (e.g. `$USER`)
* Scanning for filesystem index snapshots
* Calculating diffs between scanned snapshots
## Requirements
Python >= 3.10 is required. (CPython and PyPy are both supported)
<br><br>
`ujson` is an optional dependency for CPython for the sake of faster JSON operations.
## Installation
Backup Pro can be either installed with pip:
```shell
python3 -m pip install backup-pro
```
Or it can be installed from the source:
```shell
git clone https://github.com/simsekhalit/backup-pro.git
python3 -m pip install -e ./backup-pro
```
## Manual
```
$ python3 -m backup_pro --help
usage: backup-pro [-h] [-c CONF_DIR] [-t TARGET_DIR] COMMAND ...
A comprehensive backup tool that makes the life easier when backing up/restoring configurations, files, packages of the system.
positional arguments:
COMMAND
backup backup the system
check check configurations and packages
diff calculate diff using the previous scans
restore restore the system to the previous backup point
scan scan the system to generate filesystem index snapshot that is used by the diff command
settings change settings of the backup-pro
options:
-h, --help show this help message and exit
-c CONF_DIR, --conf-dir CONF_DIR
folder that contains the backup-pro configurations. defaults to the current directory
-t TARGET_DIR, --target-dir TARGET_DIR
folder that contains the target backup file. defaults to the current directory
For more information: https://github.com/simsekhalit/backup-pro
```
### Getting Started
There are two global options that are essential for the Backup Pro:
* `-c` `--conf-dir`: The folder that contains all Backup Pro configurations (e.g. settings, metadata, indexes, etc.).
Defaults to the current directory.
* `-t` `--target-dir`: The folder that contains the target backup file as `backup-pro-data.zip`.
Defaults to the current directory.
### Backup Operation
Firstly, tracked paths should be configured in order to specify which paths should be backed up.
Each tracked path has a strategy that can be one of 'auto', 'backup-only', 'manual'.
<br>
* `auto` means that path should be automatically handled during backup/restore processes.
This is the default strategy.
* `backup-only` means that path should only be automatically backed up but never be restored.
This is mostly for archiving purposes.
* `manual` means that path should be backed up automatically but restored in a manual way.
`Meld` is supported for manual restoration process.
A tracked path can be added as the following:
```shell
python3 -m backup_pro settings add-tracked-path '$HOME/.config'
```
Additionally, strategy can be specified as well:
```shell
python3 -m backup_pro settings add-tracked-path --strategy manual '$HOME/.ssh'
```
:information_source:
> Please note that environment variables (e.g. `$HOME`, `$USER`) are supported.
> When they are given in a shell escaped way (e.g. `'$HOME'`), Backup Pro understands and treats them as variables.
> For example if `$HOME` variable is change at the moment of restore operation,
> home directory is extracted to the new value of the variable.
It's possible to exclude some subdirectories of given tracked paths:
```shell
python3 -m backup_pro settings add-tracked-path "/opt/myapp"
python3 -m backup_pro settings add-archive-exclude-path "/opt/myapp/cache"
```
A regex pattern can be specified to exclude paths during backup.
For example, following command excludes python cache files (*.pyc, *.pyo):
```shell
python3 -m backup_pro settings add-archive-exclude-pattern '.+\.py[co]$'
```
After tracked paths are all set, backup operation can be triggered:
```shell
python3 -m backup_pro backup
```
Above command results to a file named as `backup-pro-data.zip` under the path that is specified with the `--target-dir`.
### Check Operation
Every time a `backup` command is executed,
all installed packages and configurations are silently scanned behind the scene.
If new packages are installed (e.g. with `apt install`)
or some configurations are changed (e.g. with `gsettings set`), `check` command detects them and
asks how should the changes be handled.
#### Handling packages:
```
$ python3 -m backup_pro check
Choose package strategy:
d: mark as dependency
i: ignore
r: remove
t: track
S: skip
apt/gparted is detected
[d/i/r/t/S]
```
* If mark as dependency is selected, then `apt-mark auto gparted` command is going to be executed during restoration.
* If ignore is selected, then `gparted` is going to be ignored and no action is going to be taken.
* If remove is selected, then `gparted` is going to be removed with `apt purge gparted` during restoration.
* If track is selected, then `gparted` is going to be installed with `apt install gparted` during restoration.
* If skip is selected, then this package is skipped for now and it's going to be brought up again in the next `check` command.
#### Handling configurations:
```
$ python3 -m backup_pro check
Choose configuration strategy:
i: ignore
t: track
S: skip
gsettings/org.gnome.FileRoller.Listing.sort-method
<'size'
>'name'
[i/t/S]
```
* If ignore is selected, then this configuration is going to be ignored and no action is going to be taken.
* If track is selected, then this configuration is going to be restored with
the value that was recorded with the latest `backup` operation.
### Restore Operation
After the `backup` operation is executed, a file named as `backup-pro-data.zip` is generated under the path that is
specified with the `--target-dir`.
`restore` command restores the system using that file:
```shell
python3 -m backup_pro restore
```
A dry run can be executed in order to see what is going to happen during restore without actually changing anything:
```shell
python3 -m backup_pro --dry-run restore
```
If there are tracked paths with the `manual` strategy,
output of the restore command is going to contain lines as the following:
```
[M] /tmp/backup-pro-data.tmp123456/opt/mydata /opt/mydata
```
These paths should be restored manually.
Backup Pro supports running `meld` for each manually tracked path if `DIFF_CHECKER` variable is set to `meld`:
```shell
export DIFF_CHECKER=meld
python3 -m backup_pro restore
```
Furthermore, it can be forced to restore each file manually in an interactive way
regardless of whether their strategy is `auto` or `manual`:
```shell
export DIFF_CHECKER=meld
python3 -m backup_pro restore --interactive
```
### Scan & Diff Operations
Backup Pro has a mechanism for generating filesystem index snapshot on a specific point in time by scanning the filesystem.
Multiple snapshots can be generated on different times, and then they can be compared to see the differences between them.
This is useful for tracking what is going on within the filesystem.
<br><br>
Running a scan operation:
```shell
python3 -m backup_pro scan
```
After using the system for some time, `scan` operation is run again.
Following command lists the previously generated snapshots:
```
$ python3 -m backup_pro scan --list
1687685886 (2023-06-25T09:38:06)
1687865209 (2023-06-27T11:26:49)
```
`1687685886` is the key of the first snapshot. The difference between two snapshots can be compared as the following:
```shell
python3 -m backup_pro diff --from-time 1687685886 --to-time 1687865209
```
Please note that:
* `--to-time` defaults to the latest snapshot.
* `--from-time` defaults to the second-latest snapshot.
Therefore, `diff` command can be executed without any arguments in this scenario:
```shell
python3 -m backup_pro diff
```
Alternatively, `--from-time` argument can be given as a timestamp of an arbitrary point in time.
In this case, no previous snapshot exists with the given timestamp
so Backup Pro finds all the files that are changed after the given timestamp.
This is useful for some cases.
For example, if all the files that are changed within the last 30 minutes of the latest snapshot are needed,
the following yields the result:
```
$ python3 -m backup_pro scan --list
1691138286 (2023-08-04T08:38:06)
1691491328 (2023-08-08T10:42:08)
$ python3 -m diff --from-time 1691489528
...
```
Above command prints all the files in the snapshot of `1691491328 (2023-08-08T10:42:08)`
that have modification timestamp newer than `1691489528 (2023-08-08T10:12:08)`.
### Helpful Tip
Generally, system backup/restore tools require root permissions for reading from/writing to system directories.
Using virtual environments with the `sudo` command can be tricky at that point.
For a smoother experience, an executable file can be created as:
```shell
sudo touch /usr/local/bin/backup_pro
sudo chmod 755 /usr/local/bin/backup_pro
```
Following content can be written to the file using the favourite text editor.
```shell
#!/usr/bin/env bash
set -e
if [ "$UID" != 0 ]; then
exec sudo -E $(readlink -f $0) "$@"
fi
CONF_DIR="$HOME/.config"
TARGET_DIR="/opt"
VENV_PATH="$HOME/venv"
export DIFF_CHECKER="meld"
source "$VENV_PATH/bin/activate"
python3 -m backup_pro -c "$CONF_DIR" -t "$TARGET_DIR" "$@"
```
*Please remember to modify variables according to your own setup.*
Raw data
{
"_id": null,
"home_page": "",
"name": "backup-pro",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "",
"keywords": "apt,archive,backup,backup-pro,cli,configuration,diff,flatpak,gsettings,package,pro,recovery,restore,scan,snap",
"author": "",
"author_email": "Halit Simsek <mail.simsekhalit@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/7e/b9/f243d2db12a1c67023f5b0e32186b2741b8b523dc6eb8ee672aaaaf2e9e4/backup_pro-1.0.1.tar.gz",
"platform": null,
"description": "# Backup Pro\n\nA comprehensive backup tool that makes the life easier when backing up/restoring configurations, files, packages of the system.\nSome features:\n\n* Tracking installed packages (e.g. `apt` packages)\n\n* Tracking configurations (e.g. `gsettings`)\n\n* Tracking paths on the filesystem\n\n* Capability of excluding specified subdirectories\n\n* Environment variable support on tracked paths (e.g. `$USER`)\n\n* Scanning for filesystem index snapshots\n\n* Calculating diffs between scanned snapshots\n\n## Requirements\n\nPython >= 3.10 is required. (CPython and PyPy are both supported)\n<br><br>\n`ujson` is an optional dependency for CPython for the sake of faster JSON operations.\n\n## Installation\n\nBackup Pro can be either installed with pip:\n\n```shell\npython3 -m pip install backup-pro\n```\n\nOr it can be installed from the source:\n\n```shell\ngit clone https://github.com/simsekhalit/backup-pro.git\npython3 -m pip install -e ./backup-pro\n```\n\n## Manual\n\n```\n$ python3 -m backup_pro --help\nusage: backup-pro [-h] [-c CONF_DIR] [-t TARGET_DIR] COMMAND ...\n\nA comprehensive backup tool that makes the life easier when backing up/restoring configurations, files, packages of the system.\n\npositional arguments:\n COMMAND\n backup backup the system\n check check configurations and packages\n diff calculate diff using the previous scans\n restore restore the system to the previous backup point\n scan scan the system to generate filesystem index snapshot that is used by the diff command\n settings change settings of the backup-pro\n\noptions:\n -h, --help show this help message and exit\n -c CONF_DIR, --conf-dir CONF_DIR\n folder that contains the backup-pro configurations. defaults to the current directory\n -t TARGET_DIR, --target-dir TARGET_DIR\n folder that contains the target backup file. defaults to the current directory\n\nFor more information: https://github.com/simsekhalit/backup-pro\n```\n\n### Getting Started\n\nThere are two global options that are essential for the Backup Pro:\n\n* `-c` `--conf-dir`: The folder that contains all Backup Pro configurations (e.g. settings, metadata, indexes, etc.).\nDefaults to the current directory.\n\n* `-t` `--target-dir`: The folder that contains the target backup file as `backup-pro-data.zip`.\nDefaults to the current directory.\n\n### Backup Operation\n\nFirstly, tracked paths should be configured in order to specify which paths should be backed up.\nEach tracked path has a strategy that can be one of 'auto', 'backup-only', 'manual'.\n<br>\n* `auto` means that path should be automatically handled during backup/restore processes.\nThis is the default strategy.\n\n* `backup-only` means that path should only be automatically backed up but never be restored.\nThis is mostly for archiving purposes.\n\n* `manual` means that path should be backed up automatically but restored in a manual way.\n`Meld` is supported for manual restoration process.\n\nA tracked path can be added as the following:\n\n```shell\npython3 -m backup_pro settings add-tracked-path '$HOME/.config'\n```\n\nAdditionally, strategy can be specified as well:\n\n```shell\npython3 -m backup_pro settings add-tracked-path --strategy manual '$HOME/.ssh'\n```\n\n:information_source:\n\n> Please note that environment variables (e.g. `$HOME`, `$USER`) are supported.\n> When they are given in a shell escaped way (e.g. `'$HOME'`), Backup Pro understands and treats them as variables.\n> For example if `$HOME` variable is change at the moment of restore operation, \n> home directory is extracted to the new value of the variable.\n\nIt's possible to exclude some subdirectories of given tracked paths:\n\n```shell\npython3 -m backup_pro settings add-tracked-path \"/opt/myapp\"\npython3 -m backup_pro settings add-archive-exclude-path \"/opt/myapp/cache\"\n```\n\nA regex pattern can be specified to exclude paths during backup.\nFor example, following command excludes python cache files (*.pyc, *.pyo):\n\n```shell\npython3 -m backup_pro settings add-archive-exclude-pattern '.+\\.py[co]$'\n```\n\nAfter tracked paths are all set, backup operation can be triggered:\n\n```shell\npython3 -m backup_pro backup\n```\n\nAbove command results to a file named as `backup-pro-data.zip` under the path that is specified with the `--target-dir`.\n\n### Check Operation\n\nEvery time a `backup` command is executed,\nall installed packages and configurations are silently scanned behind the scene.\nIf new packages are installed (e.g. with `apt install`)\nor some configurations are changed (e.g. with `gsettings set`), `check` command detects them and\nasks how should the changes be handled.\n\n#### Handling packages:\n\n```\n$ python3 -m backup_pro check\nChoose package strategy:\nd: mark as dependency\ni: ignore\nr: remove\nt: track\nS: skip\n\napt/gparted is detected\n[d/i/r/t/S]\n```\n\n* If mark as dependency is selected, then `apt-mark auto gparted` command is going to be executed during restoration.\n* If ignore is selected, then `gparted` is going to be ignored and no action is going to be taken.\n* If remove is selected, then `gparted` is going to be removed with `apt purge gparted` during restoration.\n* If track is selected, then `gparted` is going to be installed with `apt install gparted` during restoration.\n* If skip is selected, then this package is skipped for now and it's going to be brought up again in the next `check` command.\n\n#### Handling configurations:\n\n```\n$ python3 -m backup_pro check\nChoose configuration strategy:\ni: ignore\nt: track\nS: skip\n\ngsettings/org.gnome.FileRoller.Listing.sort-method\n<'size'\n>'name'\n[i/t/S]\n```\n\n* If ignore is selected, then this configuration is going to be ignored and no action is going to be taken.\n* If track is selected, then this configuration is going to be restored with\nthe value that was recorded with the latest `backup` operation.\n\n### Restore Operation\n\nAfter the `backup` operation is executed, a file named as `backup-pro-data.zip` is generated under the path that is\nspecified with the `--target-dir`.\n`restore` command restores the system using that file:\n\n```shell\npython3 -m backup_pro restore\n```\n\nA dry run can be executed in order to see what is going to happen during restore without actually changing anything:\n\n```shell\npython3 -m backup_pro --dry-run restore\n```\n\nIf there are tracked paths with the `manual` strategy,\noutput of the restore command is going to contain lines as the following:\n\n```\n[M] /tmp/backup-pro-data.tmp123456/opt/mydata /opt/mydata\n```\n\nThese paths should be restored manually.\nBackup Pro supports running `meld` for each manually tracked path if `DIFF_CHECKER` variable is set to `meld`:\n\n```shell\nexport DIFF_CHECKER=meld\npython3 -m backup_pro restore\n```\n\nFurthermore, it can be forced to restore each file manually in an interactive way\nregardless of whether their strategy is `auto` or `manual`:\n\n```shell\nexport DIFF_CHECKER=meld\npython3 -m backup_pro restore --interactive\n```\n\n### Scan & Diff Operations\n\nBackup Pro has a mechanism for generating filesystem index snapshot on a specific point in time by scanning the filesystem.\nMultiple snapshots can be generated on different times, and then they can be compared to see the differences between them. \nThis is useful for tracking what is going on within the filesystem.\n<br><br>\nRunning a scan operation:\n\n```shell\npython3 -m backup_pro scan\n```\n\nAfter using the system for some time, `scan` operation is run again.\nFollowing command lists the previously generated snapshots:\n\n```\n$ python3 -m backup_pro scan --list\n1687685886 (2023-06-25T09:38:06)\n1687865209 (2023-06-27T11:26:49)\n```\n\n`1687685886` is the key of the first snapshot. The difference between two snapshots can be compared as the following:\n\n```shell\npython3 -m backup_pro diff --from-time 1687685886 --to-time 1687865209\n```\n\nPlease note that:\n* `--to-time` defaults to the latest snapshot.\n* `--from-time` defaults to the second-latest snapshot.\n\nTherefore, `diff` command can be executed without any arguments in this scenario:\n\n```shell\npython3 -m backup_pro diff\n```\n\nAlternatively, `--from-time` argument can be given as a timestamp of an arbitrary point in time.\nIn this case, no previous snapshot exists with the given timestamp\nso Backup Pro finds all the files that are changed after the given timestamp.\nThis is useful for some cases.\nFor example, if all the files that are changed within the last 30 minutes of the latest snapshot are needed,\nthe following yields the result:\n\n```\n$ python3 -m backup_pro scan --list\n1691138286 (2023-08-04T08:38:06)\n1691491328 (2023-08-08T10:42:08)\n\n$ python3 -m diff --from-time 1691489528\n...\n```\n\nAbove command prints all the files in the snapshot of `1691491328 (2023-08-08T10:42:08)`\nthat have modification timestamp newer than `1691489528 (2023-08-08T10:12:08)`.\n\n### Helpful Tip\nGenerally, system backup/restore tools require root permissions for reading from/writing to system directories.\nUsing virtual environments with the `sudo` command can be tricky at that point.\nFor a smoother experience, an executable file can be created as:\n\n```shell\nsudo touch /usr/local/bin/backup_pro\nsudo chmod 755 /usr/local/bin/backup_pro\n```\n\nFollowing content can be written to the file using the favourite text editor.\n\n```shell\n#!/usr/bin/env bash\nset -e\n\nif [ \"$UID\" != 0 ]; then\n exec sudo -E $(readlink -f $0) \"$@\"\nfi\n\nCONF_DIR=\"$HOME/.config\"\nTARGET_DIR=\"/opt\"\nVENV_PATH=\"$HOME/venv\"\n\nexport DIFF_CHECKER=\"meld\"\n\nsource \"$VENV_PATH/bin/activate\"\npython3 -m backup_pro -c \"$CONF_DIR\" -t \"$TARGET_DIR\" \"$@\"\n```\n\n*Please remember to modify variables according to your own setup.*\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2023 Halit \u015eim\u015fek Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "A comprehensive backup tool that makes the life easier when backing up/restoring configurations, files, packages of the system.",
"version": "1.0.1",
"project_urls": {
"Homepage": "https://github.com/simsekhalit/backup-pro"
},
"split_keywords": [
"apt",
"archive",
"backup",
"backup-pro",
"cli",
"configuration",
"diff",
"flatpak",
"gsettings",
"package",
"pro",
"recovery",
"restore",
"scan",
"snap"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e7bdae442b72dd36c8885a339692080994cabf537c893dd22b63b5a275d1b744",
"md5": "87b7bbd01f7ffc7f6b91c282fe3e2380",
"sha256": "0ade6426b6d992ff98e0468319968cdbaebc906a1ba7787622847717d558a02b"
},
"downloads": -1,
"filename": "backup_pro-1.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "87b7bbd01f7ffc7f6b91c282fe3e2380",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 28764,
"upload_time": "2023-08-19T14:17:21",
"upload_time_iso_8601": "2023-08-19T14:17:21.798905Z",
"url": "https://files.pythonhosted.org/packages/e7/bd/ae442b72dd36c8885a339692080994cabf537c893dd22b63b5a275d1b744/backup_pro-1.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7eb9f243d2db12a1c67023f5b0e32186b2741b8b523dc6eb8ee672aaaaf2e9e4",
"md5": "b778d1f960ed3512505381ad9c5a2690",
"sha256": "4f339de562af78cf193db91872eda25dfc886cf601c2d0e380116e7c4ff82b5c"
},
"downloads": -1,
"filename": "backup_pro-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "b778d1f960ed3512505381ad9c5a2690",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 21912,
"upload_time": "2023-08-19T14:17:23",
"upload_time_iso_8601": "2023-08-19T14:17:23.779116Z",
"url": "https://files.pythonhosted.org/packages/7e/b9/f243d2db12a1c67023f5b0e32186b2741b8b523dc6eb8ee672aaaaf2e9e4/backup_pro-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-19 14:17:23",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "simsekhalit",
"github_project": "backup-pro",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "backup-pro"
}