|
1 | | -# OZO Rdiff Backup |
2 | | - |
| 1 | +# OZO Rdiff Backup Installation and Configuration |
3 | 2 | ## Overview |
| 3 | +This script automates the use of `rdiff-backup` to perform incremental backups of remote linux systems over SSH. It will mount a dedicated volume to `/srv/ozo-rdiff`, generate an increment, perform increment maintenance, and unmount the volume. It runs with no arguments. When executed, it iterates through the _CONF_ files in `/etc/ozo-rdiff-backup.conf.d` and performs the job. |
4 | 4 |
|
5 | | -This script automates the use of rdiff-backup to perform incremental backups of remote linux systems over SSH. It will mount a dedicated volume, generate an increment, perform increment maintenance, and unmount the volume. |
6 | | - |
7 | | -It runs with no arguments. When executed, it iterates through the *CONF* files in `LCONF_DIR` (`/etc/ozo-rdiff-backup.conf.d`) and performs the configured rdiff-backup job. |
8 | | - |
9 | | -Please visit https://onezeroone.dev to learn more about this script and my other work. |
| 5 | +## Installation and Configuration |
| 6 | +Choose an _rdiff-backup system_ for running the script and storing the incremental backups. The hosts that are backed up are the _remote system(s)_. |
10 | 7 |
|
11 | | -## Setup and Configuration |
| 8 | +### Installation |
| 9 | +To install this script on your rdiff-backup system, you must first register the One Zero One repository. |
12 | 10 |
|
13 | | -Choose an "Rdiff-Backup System" for running the script and storing the incremental backups. The hosts that are backed up are the "Remote System(s)" |
| 11 | +#### AlmaLinux 10, Red Hat Enterprise Linux 10, Rocky Linux 10 (RPM) |
| 12 | +In a `root` shell: |
14 | 13 |
|
15 | | -### Designate a Partition for Rdiff-Backup Operations |
| 14 | +```bash |
| 15 | +rpm -Uvh https://repositories.onezeroone.dev/el/10/noarch/ozo-rdiff-backup-1.0.0-1.el10.noarch.rpm |
| 16 | +rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-ONEZEROONE |
| 17 | +dnf repolist |
| 18 | +dnf -y install ozo-rdiff-backup |
| 19 | +``` |
16 | 20 |
|
17 | | -This script requires a dedicated volume that is mounted before running rdiff-backup jobs and unmounted when they are complete. On the Rdiff-Backup System (as `root`): |
| 21 | +#### Debian (DEB) |
| 22 | +PENDING. |
18 | 23 |
|
19 | | -- Create a partition (this could be on an external device) for storing rdiff increments and format it with the filesystem of your choice. This example uses *XFS*. |
20 | | -- Obtain the UUID of your filesystem with the `blkid` command. |
21 | | -- Create a mountpoint e.g., `/srv/rdiff`. |
22 | | -- Test mounting the partition by UUID with with e.g., where "xxx..." is your `UUID`: |
| 24 | +### Configuration |
| 25 | +#### Designate a Partition for Rdiff-Backup Operations |
| 26 | +This script requires a dedicated volume that is mounted before running rdiff-backup jobs and unmounted when they are complete. On the rdiff-backup system (as `root`): |
23 | 27 |
|
24 | | - `# mount UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" /srv/rdiff` |
| 28 | +* Designate a partition (this could be on an external device) for storing rdiff increments and format it with the filesystem of your choice. |
| 29 | +* Obtain the UUID of your filesystem with the `blkid` command. |
| 30 | +* Test mounting the partition by UUID with with e.g., where "xxx..." is your `UUID`: |
25 | 31 |
|
26 | | -- Unmount the partition with `# umount /srv/rdiff` |
27 | | -- Add a *noauto* entry in `/etc/fstab` for your UUID, e.g.: |
| 32 | + `mount UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" /srv/ozo-rdiff` |
28 | 33 |
|
29 | | - `UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /srv/rdiff xfs noauto 0 0` |
| 34 | +* Unmount the partition |
30 | 35 |
|
31 | | -### Clone the Repository and Copy Files |
| 36 | + `umount /srv/ozo-rdiff` |
32 | 37 |
|
33 | | -Clone this repository to a temporary directory on the Rdiff-Backup System. Then (as `root`): |
| 38 | +* Add a *noauto* entry in `/etc/fstab` for your UUID, e.g.: |
34 | 39 |
|
35 | | -- Copy `rdiff-backup.sh` to `/etc/cron.daily` and set permissions to `rwx------` (`0700`) |
36 | | -- Copy `rdiff-backup.conf` to `/etc` |
37 | | -- Modify `/etc/rdiff-backup.conf` to suit your environment: |
| 40 | + `UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /srv/ozo-rdiff xfs noauto 0 0` |
38 | 41 |
|
39 | | - |Variable|Example Value|Description| |
40 | | - |--------|-------------|-----------| |
41 | | - |LCONF_DIR|`"/etc/rdiff-backup.conf.d"`|Directory where the scipt will find rdiff-backup job CONF files| |
42 | | - |LUUID|`"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"`|The UUID of the partition designated for rdiff-backup operations| |
43 | | - |LMOUNTPOINT|`"/srv/rdiff"`|The mountpoint for the rdiff-backup volume| |
44 | | - |LBACKUP_DIRNAME|`"backup"`|Name of the subdirectory of LMOUNTPOINT for storing backup increments| |
45 | | - LRESTORE_DIRNAME|`"restore"`|Name of the subdirectory of LMOUNTPOINT that can be used for restore operations| |
46 | | - |RDEF_INCLUDES|`"/etc,/home,/root,/usr/local,/var"`|Directories to include for every job| |
47 | | - |RDEF_EXCLUDES|`"/,/var/lib/mysql"`|Directories to exclude from every job| |
48 | | - |LFSCK_DAY|`1`|Day to run `fsck` on the `UUID`; Sunday=0 through Saturday=6| |
| 42 | +#### Configure ozo-rdiff-backup.conf |
| 43 | +Edit `/etc/ozo-rdiff-backup.conf` and set `LUUID` to the UUID you identified above. Review the remaining variables: |
49 | 44 |
|
50 | | -- Create `/etc/rdiff-backup.conf.d` |
51 | | -- Use `rdiff-host.example.com.conf` as a template to create a *CONF* file in `/etc/rdiff-backup.conf.d` for each Remote System. |
| 45 | +|Variable|Value|Description| |
| 46 | +|--------|-----|-----------| |
| 47 | +|LBACKUP_DIRNAME|`backup`|Name of the subdirectory of `/srv/ozo-rdiff` where rdiff increments will be stored.| |
| 48 | +|LRESTORE_DIRNAME|`restore`|Name of the subdirectory of `/srv/ozo-rdiff` that can be used for restore operations.| |
| 49 | +|RDEF_INCLUDES|`/etc,/home,/root,/usr/local,/var`|Directories that will be _included_ in backup jobs for _all_ remote systems.| |
| 50 | +|RDEF_EXCLUDES|`/,/var/lib/mysql`|Directories that will be _excluded_ from backup jobs for _all_ remote systems.| |
| 51 | +|LFSCK_DAY|`1`|Day to run fsck, Sunday=0, Monday=1, Tuesday=2, Wednesday=3, Thursday=4, Friday=5, and Saturday=6.| |
52 | 52 |
|
53 | | - |Variable|Example Value|Description| |
54 | | - |--------|-------------|-----------| |
55 | | - |RHOSTUSER|`root`|User that performs rdiff-backup on the Remote System| |
56 | | - |RHOSTFQDN|`"rdiff-host.example.com"`|Fully qualified domain name of the Remote System| |
57 | | - |RSSHPORT|`22`|SSH port for establishing a connection to the remote host| |
58 | | - |RHOST_INCLUDES|`"/srv/plex,/usr/lib/plexmediaserver"`|Comma-separated list of *additional* inclusions for this remote system.| |
59 | | - |RHOST_EXCLUDES|`"/var/lib/pgsql"`|Comma-separated list of *additional* exclusions for this remote system.| |
60 | | - |RAGE|`180`|How many increments to keep (days)| |
| 53 | +#### Create Remote Host Configuration File(s) |
| 54 | +In `/etc/rdiff-backup.conf.d`, using `ozo-rdiff-remote-host.conf.example` as a template, create a *CONF* file for each remote system. Configuration file names must end in `.conf`. |
61 | 55 |
|
62 | | -### SSH Setup |
| 56 | +|Variable|Example Value|Description| |
| 57 | +|--------|-------------|-----------| |
| 58 | +|RHOSTUSER|`root`|User that performs rdiff-backup on the remote system.| |
| 59 | +|RHOSTFQDN|`"rdiff-host.example.com"`|Fully qualified domain name of the remote system.| |
| 60 | +|RSSHPORT|`22`|SSH port for establishing a connection to the remote host.| |
| 61 | +|RHOST_INCLUDES|`"/srv/plex,/usr/lib/plexmediaserver"`|Comma-separated list of *additional* inclusions for this remote system.| |
| 62 | +|RHOST_EXCLUDES|`"/var/lib/pgsql"`|Comma-separated list of *additional* exclusions for this remote system.| |
| 63 | +|RAGE|`180`|How many increments to keep (days)| |
63 | 64 |
|
64 | | -#### Rdiff-Backup System |
| 65 | +### Configure Cron |
| 66 | +Modify `/etc/cron.d/ozo-rdiff-backup` to suit your scheduling needs. The default configuration runs `ozo-rdiff-backup.sh` every day at 6:00am. |
65 | 67 |
|
66 | | -On the Rdiff-Backup System (as `root`): |
| 68 | +#### Configure Local and Remote SSH |
| 69 | +##### Rdiff-Backup System |
| 70 | +On the rdiff-backup system (as `root`): |
67 | 71 |
|
68 | | -- Generate SSH keys for the `root` user: |
| 72 | +* Generate SSH keys for the `root` user: |
69 | 73 |
|
70 | 74 | `# ssh keygen` |
71 | 75 |
|
72 | | -- Install your `root` user SSH keys to each of the Remote System(s) with e.g.: |
| 76 | +* Install your `root` user SSH keys to each of the Remote System(s) with e.g.: |
73 | 77 |
|
74 | 78 | `ssh-copy-id -i [email protected]` |
75 | 79 |
|
76 | | -#### Remote System(s) |
| 80 | +##### Remote System(s) |
| 81 | +On the remote system(s) (as `root`), install `rdiff-backup`. |
77 | 82 |
|
78 | | -On the Remote System(s) (as `root`), install `rdiff-backup`. |
79 | | - |
80 | | -- RedHat: `dnf install rdiff-backup` |
81 | | -- Debian: `apt-get install rdiff-backup` |
| 83 | +* AlmaLinux, Red Hat Enterprise Linux, Rocky Linux (DNF): `dnf install rdiff-backup` |
| 84 | +* Debian (APT): `apt-get install rdiff-backup` |
82 | 85 |
|
83 | 86 | Edit `/root/.ssh/authorized_keys` and prepend the shared key with: |
84 | 87 |
|
85 | 88 | `command="rdiff-backup server --restrict-mode read-only"` |
| 89 | + |
| 90 | +## Notes |
| 91 | +Please visit [One Zero One](https://onezeroone.dev) to learn more about other work. |
0 commit comments