|
1 |
| -# Backup.py |
2 |
| - |
3 |
| -Backup.py is your solution to backup your data! |
4 |
| - |
5 |
| -Backup.py provides the following features: |
6 |
| -- Support for incremental backups: only back up data that has changed since the previous backup |
7 |
| -- Optimize memory usage: Avoid to store the same file several times |
8 |
| -- Define backup profiles once: Use these profiles for your regular backup tasks |
9 |
| -- Easy to use: several profiles can be executed with a single command |
10 |
| - |
11 |
| -## Install |
12 |
| - |
13 |
| -Backup.py uses rsync: |
14 |
| -``` |
15 |
| -apt install rsync |
16 |
| -``` |
17 |
| - |
18 |
| -## Profile definiton |
19 |
| - |
20 |
| -Define your backup profile in the definition file "backup.xml". By default this file is searched in the same folder as backup.py. |
21 |
| - |
22 |
| -The XML structure is as follows: |
23 |
| -```xml |
24 |
| -<?xml version="1.0" encoding="UTF-8"?> |
25 |
| -<backup-profiles> |
26 |
| - <backup-profile> |
27 |
| - <name>home2nas</name> |
28 |
| - <description>Backup /home/user</description> |
29 |
| - <source>/home/user/</source> |
30 |
| - <target>/mnt/nas/user/desktop-home</target> |
31 |
| - <mode>synchronize</mode> |
32 |
| - <option>-rltvzi</option> |
33 |
| - <!-- .thumbnails: gnome thumbnails --> |
34 |
| - <option>--exclude=/.thumbnails/</option> |
35 |
| - <!-- .cache: cache data of applications --> |
36 |
| - <option>--exclude=/.cache/</option> |
37 |
| - <!-- Skip symlinks --> |
38 |
| - <option>--no-links</option> |
39 |
| - <count></count> |
40 |
| - </backup-profile> |
41 |
| -</backup-profiles> |
42 |
| -``` |
43 |
| - |
44 |
| -## Example usage |
45 |
| - |
46 |
| -List all available profiles: |
47 |
| -``` |
48 |
| -backup.py |
49 |
| -``` |
50 |
| - |
51 |
| -Start test run for profile "home2nas": |
52 |
| -``` |
53 |
| -backup.py -n --delete home2nas |
54 |
| -``` |
55 |
| - |
56 |
| -Start backup of profile named "home2nas" and delete files in target directory: |
57 |
| -``` |
58 |
| -backup.py --delete home2nas |
59 |
| -``` |
60 |
| - |
61 |
| -Start backup of profile named "home2nas" and "opt2nas". Do not delete files in target directory: |
62 |
| -``` |
63 |
| -backup.py home2nas opt2nas |
64 |
| -``` |
65 |
| - |
66 |
| -Use alisas to make backup even more easier: |
67 |
| -``` |
68 |
| -alias backup.homeopt2nas.try='backup.py -n --delete home2nas opt2nas' |
69 |
| -alias backup.homeopt2nas.run='backup.py --delete home2nas opt2nas' |
70 |
| -``` |
71 |
| - |
| 1 | +# Backup.py |
| 2 | + |
| 3 | +Backup.py is your solution to backup your data! |
| 4 | + |
| 5 | +Backup.py provides the following features: |
| 6 | +- Support for incremental backups: only back up data that has changed since the previous backup |
| 7 | +- Optimize memory usage: Avoid to store the same file several times |
| 8 | +- Define backup profiles once: Use these profiles for your regular backup tasks |
| 9 | +- Easy to use: several profiles can be executed with a single command |
| 10 | + |
| 11 | +## Install |
| 12 | +1. Install Python3 as follows in Ubuntu/Debian Linux: |
| 13 | +``` |
| 14 | +sudo apt install python3.6 |
| 15 | +``` |
| 16 | + |
| 17 | +2. Install external applications: |
| 18 | +``` |
| 19 | +sudo apt install rsync |
| 20 | +``` |
| 21 | + |
| 22 | +2. Download Backup.py and set execute permissions: |
| 23 | +``` |
| 24 | +curl -LJO https://raw.githubusercontent.com/byte-cook/backup/main/backup.py |
| 25 | +curl -LJO https://raw.githubusercontent.com/byte-cook/backup/main/osutil.py |
| 26 | +curl -LJO https://raw.githubusercontent.com/byte-cook/backup/main/xmlutil.py |
| 27 | +chmod +x backup.py |
| 28 | +``` |
| 29 | + |
| 30 | +## Profile definiton |
| 31 | + |
| 32 | +Define your backup profile in the definition file "backup.xml". By default, this file is searched in the same folder as backup.py. |
| 33 | + |
| 34 | +You can create an example definition file with this command: |
| 35 | +``` |
| 36 | +backup.py -t > backup.xml |
| 37 | +``` |
| 38 | +The XML structure is as follows: |
| 39 | + |
| 40 | +```xml |
| 41 | +<?xml version="1.0" encoding="UTF-8"?> |
| 42 | +<backup-profiles> |
| 43 | + <backup-profile> |
| 44 | + <name>home2nas</name> |
| 45 | + <description>home directory to NAS</description> |
| 46 | + <source>/home/user</source> |
| 47 | + <target>/mnt/nas/user/backup-home</target> |
| 48 | + <mode>incremental</mode> |
| 49 | + <option>-rltvzi</option> |
| 50 | + <!-- add more rsync options here --> |
| 51 | + <count>2</count> |
| 52 | + </backup-profile> |
| 53 | + <backup-profile> |
| 54 | + <name>opt2nas</name> |
| 55 | + <description>/opt to NAS</description> |
| 56 | + <source>/opt</source> |
| 57 | + <target>/mnt/nas/user/backup-opt</target> |
| 58 | + <mode>synchronize</mode> |
| 59 | + </backup-profile> |
| 60 | +</backup-profiles> |
| 61 | +``` |
| 62 | + |
| 63 | +## Example usage |
| 64 | + |
| 65 | +List all available profiles: |
| 66 | +``` |
| 67 | +backup.py |
| 68 | +``` |
| 69 | +List profiles details for "home2nas": |
| 70 | +``` |
| 71 | +backup.py -p home2nas |
| 72 | +``` |
| 73 | + |
| 74 | +Start test run for profile "home2nas": |
| 75 | +``` |
| 76 | +backup.py -n --delete home2nas |
| 77 | +``` |
| 78 | + |
| 79 | +Start backup of profile named "home2nas" and delete files in target directory if they do not exist in the source: |
| 80 | +``` |
| 81 | +backup.py --delete home2nas |
| 82 | +``` |
| 83 | + |
| 84 | +Start backup of profile named "home2nas" and "opt2nas". Do not delete files in target directory: |
| 85 | +``` |
| 86 | +backup.py home2nas opt2nas |
| 87 | +``` |
| 88 | + |
| 89 | +Use alisas to make backup even more easier: |
| 90 | +``` |
| 91 | +alias backup.homeopt2nas.try='backup.py -n --delete home2nas opt2nas' |
| 92 | +alias backup.homeopt2nas.run='backup.py --delete home2nas opt2nas' |
| 93 | +``` |
| 94 | + |
0 commit comments