mirror of
https://github.com/wrolpi/wrolpi-help.git
synced 2026-10-25 18:40:11 -04:00
1.9 KiB
1.9 KiB
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.
- SSH/login to the primary WROLPi, add a password for the "wrolpi" user
sudo -u wrolpi passwd
- SSH/login into the backup WROLPi
- Switch to the "wrolpi" user:
sudo su - wropi
- Generate SSH keys for the wrolpi user:
ssh-keygen
- Copy ssh keys to the primary WROLPi (using the password from step 1)
ssh-copy-id wrolpi@PRIMARY_IP_ADDRESS
- Ensure the backup can login to the primary by ssh'ing into it from the backup
ssh wrolpi@PRIMARY_IP_ADDRESS
- Copy all files from the primary to the backup
rsync -avrle ssh wrolpi@PRIMARY_IP_ADDRESS:/media/wrolpi/* /media/wrolpi
- Switch to the "wrolpi" user:
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.
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" \
--exclude="tags" \
-avue ssh \
wrolpi@PRIMARY_IP_ADDRESS:/media/wrolpi/* \
/media/wrolpi/ \
2>&1 >> ${logfile}
echo end $(date +"%Y-%m-%d %H:%M:%S") >> ${logfile}
EOF
- Modify the above file (at
/home/wrolpi/backup_wrolpi.sh), replacingPRIMARY_IP_ADDRESSwith the correct IP address. - Modify the crontab of the "wrolpi" user so this script runs daily
sudo -u wrolpi crontab -e
- Add the following cron entry to run the backup script
0 4 * * * /bin/bash -l /home/wrolpi/backup_wrolpi.sh