Adding backup instructions.

This commit is contained in:
Roland 2024-05-08 20:07:19 -06:00
parent a2ab307a17
commit bb8ff9f25f
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
4 changed files with 57 additions and 3 deletions

View file

@ -14,7 +14,7 @@ that have recently been created, and are not yet in the database.
WROLPi can search any file in your media directory, this can only be accomplished after a full files refresh has been
completed.
> To refresh all your files, click the **Files** link in the top navigation bar, then click **Refresh All** found at the
> To refresh all your files, click the **Files** link in the top navigation bar, then click **Refresh** found at the
> bottom of the files table.
## Files Tools

53
docs/system/backup.md Normal file
View file

@ -0,0 +1,53 @@
# Backup
## Backup from one WROLPi to another
As of the writing of this tutorial, WROLPi does not have an official way to back up a WROLPi. The current workaround
is to use rsync with a manual refresh.
Follow these steps to automate backup of your WROLPi.
1. SSH/login to the primary WROLPi, add a password for the "wrolpi" user
- `sudo -u wrolpi passwd`
2. SSH/login into the backup WROLPi
1. Switch to the "wrolpi" user:
- `sudo su - wropi`
2. Generate SSH keys for the wrolpi user:
- `ssh-keygen`
3. Copy ssh keys to the primary WROLPi (using the password from step 1)
- `ssh-copy-id wrolpi@PRIMARY_IP_ADDRESS`
4. Ensure the backup can login to the primary by ssh'ing into it from the backup
- `ssh wrolpi@PRIMARY_IP_ADDRESS`
5. Copy all files from the primary to the backup
- `rsync -avrle ssh wrolpi@PRIMARY_IP_ADDRESS:/media/wrolpi/* /media/wrolpi`
Files are now synchronized, now you need to automate it. Copy/paste the following into the shell of the backup WROLPI,
it will create a bash script that will copy files from the primary to the backup WROLPi.
```shell
cat > /home/wrolpi/backup_wrolpi.sh << 'EOF'
#! /usr/bin/env bash
logfile=/home/wrolpi/wrolpi.log
echo >> ${logfile}
echo >> ${logfile}
echo start $(date +"%Y-%m-%d %H:%M:%S") >> ${logfile}
/usr/bin/rsync \
--exclude="lost+found" \
-avue ssh \
wrolpi@PRIMARY_IP_ADDRESS:/media/wrolpi/* \
/media/wrolpi/ \
2>&1 >> ${logfile}
echo end $(date +"%Y-%m-%d %H:%M:%S") >> ${logfile}
EOF
```
1. Modify the above file (at `/home/wrolpi/backup_wrolpi.sh`), replacing `PRIMARY_IP_ADDRESS` with the correct IP
address.
2. Modify the crontab of the "wrolpi" user so this script runs daily
- `sudo -u wrolpi crontab -e`
3. Add the following cron entry to run the backup script
```shell
0 4 * * * /bin/bash -l /home/wrolpi/backup_wrolpi.sh
```

View file

@ -71,6 +71,7 @@ OK: Kiwix app responded
OK: The media directory exists
OK: Can modify media directory
OK: Media directory is a mounted drive
OK: Media directory files are served by nginx
OK: Config can be fetched from nginx
OK: Media directory is owned by wrolpi user

View file

@ -1,11 +1,11 @@
# Special Directories
# Special System Directories
| Path | Purpose |
|-------------------------|----------------------------------------------------------|
| `/media/wrolpi/` | The [Media Directory](#media-directory). |
| `/opt/wrolpi/` | The [source code](#wrolpi-source-directory) of WROLPi. |
| `/media/wrolpi/config/` | The [configuration files](#wrolpi-config) of the WROLPi. |
| `/opt/wrolpi-blobs/` | Contains files necessary to the repair of a WROLPi. |
| `/opt/wrolpi-blobs/` | Contains files necessary to repair a WROLPi. |
| `/opt/wrolpi-help/` | These help files. |
## Media Directory