Skip to content

Commit a4f7284

Browse files
alievertzAndy Lievertz
andauthored
All features implemented; v1.0.0
* save commit * All features implemented; v1.0.0 --------- Co-authored-by: Andy Lievertz <[email protected]>
1 parent bbb4cf6 commit a4f7284

10 files changed

+627
-432
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
OZO Rdiff Backup Change Log
2+
3+
|Date|Version|Comment|
4+
|`2021-Feb-26`|1.0.0|Initial release.|

README.md

Lines changed: 60 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,91 @@
1-
# OZO Rdiff Backup
2-
1+
# OZO Rdiff Backup Installation and Configuration
32
## 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.
44

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)_.
107

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.
1210

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:
1413

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+
```
1620

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.
1823

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`):
2327

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`:
2531

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`
2833

29-
`UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /srv/rdiff xfs noauto 0 0`
34+
* Unmount the partition
3035

31-
### Clone the Repository and Copy Files
36+
`umount /srv/ozo-rdiff`
3237

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.:
3439

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`
3841

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:
4944

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.|
5252

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`.
6155

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)|
6364

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.
6567

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`):
6771

68-
- Generate SSH keys for the `root` user:
72+
* Generate SSH keys for the `root` user:
6973

7074
`# ssh keygen`
7175

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.:
7377

7478
`ssh-copy-id -i [email protected]`
7579

76-
#### Remote System(s)
80+
##### Remote System(s)
81+
On the remote system(s) (as `root`), install `rdiff-backup`.
7782

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`
8285

8386
Edit `/root/.ssh/authorized_keys` and prepend the shared key with:
8487

8588
`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.

ozo-rdiff-backup

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Field Allowed values
2+
# ----- --------------
3+
# minute 0-59
4+
# hour 0-23
5+
# day of month 1-31
6+
# month 1-12
7+
# day of week 0-7 (0,7 = Sunday)
8+
9+
00 06 * * * root /usr/sbin/ozo-rdiff-backup.sh

ozo-rdiff-backup.conf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# UUID of the rdiff-backup volume
2+
LUUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
3+
# Name of the subdirectory of /srv/ozo-rdiff where rdiff increments will be stored
4+
LBACKUP_DIRNAME="backup"
5+
# Name of the subdirectory of /srv/ozo-rdiff that can be used for restore operations
6+
LRESTORE_DIRNAME="restore"
7+
# Directories that will be included in backup jobs for all remote systems
8+
RDEF_INCLUDES="/etc,/home,/root,/usr/local,/var"
9+
# Directories that will be excluded from backup jobs for all remote systems
10+
RDEF_EXCLUDES="/,/var/lib/mysql"
11+
# Day to run fsck, Sunday=0 through Saturday=6
12+
LFSCK_DAY=1

0 commit comments

Comments
 (0)