-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,64 @@ | ||
# UniFi | ||
|
||
UniFi scripts and other goodies | ||
|
||
#Back-up your UniFi autobackup file | ||
|
||
##Before you start | ||
|
||
This script makes use of rclone and installs it but you need to manually go through the "rclone config" steps in the setup. There are many different sorts of cloudstorage providers provided in the rclone config. While many use the same settings some require additional steps especially on headless machines. | ||
|
||
Please read up on [Rclone][https://rclone.org] | ||
|
||
##Rclone config | ||
|
||
**TIPS:** | ||
|
||
[Rclone][https://rclone.org] | ||
[Configuring rclone on a remote / headless machine][https://rclone.org/remote_setup/] | ||
|
||
---------------- | ||
|
||
Rclone references **"remote:"** a lot, for example to list the top directory of most Cloudprovider you use | ||
|
||
`rclone lsd remote:` | ||
|
||
To list all the files you use | ||
|
||
`rclone ls remote:` | ||
|
||
the **"remote"** is actually **the name you choose for your connector** when running rclone config. | ||
So if you name your connector OneDrive it will be | ||
|
||
`rclone lsd OneDrive:` | ||
|
||
If you name it UniFi-Backup it will be | ||
|
||
`rclone lsd UniFi-Backup` | ||
|
||
That seems one of the biggest misconceptions from new users when using rclone and reading the docs. | ||
|
||
---------------- | ||
|
||
Want to save your files in another place then the main directory? Just copy the path and add it behind the remote. | ||
|
||
`rclone lsd remote:Documents/UniFi/Backup` | ||
|
||
Always use `/` even when on Windows. | ||
|
||
## Unifi Backup Setup (unifi_backup_setup.sh) | ||
|
||
`sudo wget https://raw.githubusercontent.com/dc911x/UniFi/master/unifi_backup_setup.sh -O /usr/local/bin/unifi_backup_setup.sh | ||
sudo chmod +x /usr/local/bin/unifi_backup_setup.sh` | ||
|
||
Run the script: | ||
|
||
`sudo /usr/local/bin/unifi_backup_setup.sh` | ||
|
||
## UniFi Backup (unifi_backup.sh) | ||
|
||
After running the setup edit unifi_backup.sh with your favorite editor and add the correct remote from Rclone and path where you want to save the .unf file. | ||
|
||
`sudo nano -w /usr/local/bin/unifi_backup.sh` | ||
|
||
**That's all folks!** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
# unifi_backup.sh | ||
# UniFi Back-up cron-job | ||
# by Jelle Revyn <https://www.jelle.revyn.xyz/> | ||
# Part of unifi_backup_setup.sh | ||
|
||
# Backup directory path | ||
UNIFIBACKUP_DIR=/var/lib/unifi/data/backup/autobackup/ | ||
# Rclone directory path | ||
RCLONEBACKUP_DIR=remote:path | ||
|
||
#Copy all files that are not older then a day and filter out autobackup.json | ||
rclone --filter "- *.json" --max-age 1d copy ${UNIFIBACKUP_DIR} ${RCLONEBACKUP_DIR} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
# unifi_backup_setup.sh | ||
# UniFi Back-up to cloudprovider using rclone | ||
# by Jelle Revyn <https://www.jelle.revyn.xyz/> | ||
# Version 1.0 | ||
# Last Updated 23/08/2019 | ||
|
||
# Read access to UniFi backup directory | ||
sudo chmod -R 705 /var/lib/unifi/backup/ | ||
|
||
# Install rclone and go through the process for your cloud provider. | ||
curl https://rclone.org/install.sh | sudo bash | ||
|
||
# Configure rclone | ||
|
||
rclone config | ||
|
||
# Download backupfile | ||
sudo wget https://raw.githubusercontent.com/dc911x/UniFi/master/unifi_backup.sh -O /usr/local/bin/unifi_backup.sh | ||
sudo chmod +x /usr/local/bin/unifi_backup.sh | ||
|
||
#Schedule cronjob to run unifi_backup.sh every Sunday at 23u45, please make sure your autobackup is set to sunday BEFORE 23u45 (10min before should be fine) | ||
#Don't forget to edit unifi_backup.sh with the correct settings | ||
sudo crontab -l | { cat; echo "45 23 * * 0 /usr/local/bin/unifi_backup.sh"; } | crontab - |