This script is a backup power scheduler for Raspberry Pi 5 (or older Pi w/ RTC module) running as a backup server for DSM HyperBackup. It lets you shut down your Raspberry Pi to save energy after the backup is done and then automatically start it up before the next backup event.
🎁 Special thanks to N4S4's Python wrapper: synology-api
-
Creat a
Scripts
folder under$HOME
mkdir ~/Scripts && cd ./Scripts
-
Clone the repository:
git clone https://github.com/driftkingtw/pi-backup-power-scheduler.git
-
Create and activate a Python virtual environment:
cd pi-backup-power-scheduler/ python -m venv venv source venv/bin/activate
-
Install the required dependencies:
pip install -r requirements.txt
-
Add
.env
configurationcp .env.example .env
-
Configure environment variables in the
.env
file.nano .env
DSM_IP=YOUR_SYNOLOGY_DSM_IP DSM_PORT=HTTPS_DEFAULT_5001 DSM_ACCOUNT=YOUR_ACCOUNT DSM_PASSWORD=YOUR_PASSWORD DSM_TOTP_SECRET=YOUR_TOTP_SECRET NEXT_BOOT_TIME=LINUX_DATE_STRING (Like 'tomorrow 03:50')
-
Run script
python main.py
-
Configure HyperBackup service and backup schedule in DSM
-
Follwing the Pi Official RTC Guide to enable the low-power mode for wakealarm on Pi
-
(Optional) Connect RTC backup battery
-
Edit crontab
crontab -e
-
Add cron task (replace
USERNAME
with your username and adjust cron schedule to your liking, ex: set it to run 30 minutes after the scheduled backup starts)HOME=/home/USERNAME 30 4 * * * /bin/bash -c 'source $HOME/Scripts/pi-backup-power-scheduler/venv/bin/activate && python $HOME/Scripts/pi-backup-power-scheduler/main.py'
-
Make sure your script has executable permissions
chmod +x ~/Scripts/pi-backup-power-scheduler/main.py
-
Check crontab task with
crontab -l
This project is licensed under the MIT License. See the LICENSE.md file for more details.