After a bit of research, reading and digging around this week, I was able to setup automated backups of CumulusMX to an external host on the network, using the cumulusmx.sh bash script and the built-in cron scheduler.
Prerequisite for this task is that you already have CumulusMX installed and successfully running on your Raspberry Pi. In this case, I am running a Raspberry Pi 3 with Raspbian (Jessie) with Noobs v1.9.0 and I'm using the built-in wireless network interface on the Pi3. I'll give brief outlines below only, and presume that you have some basic understanding and knowledge of Linux and Windows.
Mountpoint to External Host
First step is to setup a mountpoint to an external host on your network. This can be a NAS device, a server or a workstation on your network. On the selected host, create a new user and password, something like 'Raspi' and p@ssw0rD for example. Then create a new share, something like "backup", and give the new user full RW access to the share. Then create a folder in the new share called Backup_CumulusMX, to hold your backups.
We'll go with the examples above, and presume the host is called "server" and its IP address is 192.168.1.1.
You'll need cifs on your Pi, and it seems to be there preinstalled on the later releases of Raspbian. Check if it is installed with:
dpkg -s cifs-util
If cifs is not installed, fetch it with:
sudo apt-get install cifs-utils
Now you need to create a new directory for the mountpoint on your Pi. Open a shell and do the following:
cd /mnt
sudo mkdir server
sudo mkdir /server/backup
Now you need to create the new mountpoint in the fstab file for cifs.
sudo nano /etc/fstab
Add the following line to the bottom of the file (note this is all one line):
//192.168.1.1/backup /mnt/server/backup username=raspi,password=p@ssw0rD,uid=1000,gid=1000,iocharset=utf8 0 0
Now mount the new drive share:
sudo mount –a
Give the mount a few seconds to complete, and if all was well you should be able to browse down your MNT path into the backup share that you created on your network host:
cd /mnt/server/backup/Backup_CumulusMX
At this point, if you copy a file to the share on that network host, from your Windows PC, you should see it on your Raspberry Pi now (ls -l).
To test permissions are correct on the share, on the Raspberri Pi create a test file:
cd /mnt/server/backup/Backup_CumulusMX
sudo nano test1.txt
Save and exit nono editor, and you should see the file in the share, on the host device. If you got this far, all is well with your mountpoint to the external host
Setup Backups in CumulusMX
Go back to your home drive on the Pi, with cd ~
Then CD into the CumulusMX directory. Edit the CumulusMX config file:
sudo nano cumulusmxsh.conf
Add the cifs share as the backup path:
BACKUPFOLDER= "/mnt/server/backup/Backup_CumulusMX/"
Now you can run quick manual (one off) test backup:
sudo ./cumulusmx.sh -b -t
If this worked ok you should have a TAR backup in your network share, and your good to setup the scheduled task next.
Schedule Automated Nightly Backups
To acheive the automated backups, you'll add a scheduled task to the CRONTAB to do the nightly backups:
sudo crontab –e
if asked, select 'nano' as your editor (easiest)
Insert a new line at the bottom of the crontab file:
00 01 * * * sudo /home/pi/CumulusMX/cumulusmx.sh –b –t >> /dev/null 2>&1
Alt-X, Y to save, Enter to select the filename
This example will backup every night at 1am. By default, the cumulusmx.sh script will keep the last five backups, in a rolling window, so your backup share should never fill over time. You can edit the number of kept backups in the cumulusmxsh.conf file.
Hope this info helps. If I've made any typos or something doesn't like or work right, post below and together we'll work it out.
Cheers for now...
Mark R
Prerequisite for this task is that you already have CumulusMX installed and successfully running on your Raspberry Pi. In this case, I am running a Raspberry Pi 3 with Raspbian (Jessie) with Noobs v1.9.0 and I'm using the built-in wireless network interface on the Pi3. I'll give brief outlines below only, and presume that you have some basic understanding and knowledge of Linux and Windows.
Mountpoint to External Host
First step is to setup a mountpoint to an external host on your network. This can be a NAS device, a server or a workstation on your network. On the selected host, create a new user and password, something like 'Raspi' and p@ssw0rD for example. Then create a new share, something like "backup", and give the new user full RW access to the share. Then create a folder in the new share called Backup_CumulusMX, to hold your backups.
We'll go with the examples above, and presume the host is called "server" and its IP address is 192.168.1.1.
You'll need cifs on your Pi, and it seems to be there preinstalled on the later releases of Raspbian. Check if it is installed with:
dpkg -s cifs-util
If cifs is not installed, fetch it with:
sudo apt-get install cifs-utils
Now you need to create a new directory for the mountpoint on your Pi. Open a shell and do the following:
cd /mnt
sudo mkdir server
sudo mkdir /server/backup
Now you need to create the new mountpoint in the fstab file for cifs.
sudo nano /etc/fstab
Add the following line to the bottom of the file (note this is all one line):
//192.168.1.1/backup /mnt/server/backup username=raspi,password=p@ssw0rD,uid=1000,gid=1000,iocharset=utf8 0 0
Now mount the new drive share:
sudo mount –a
Give the mount a few seconds to complete, and if all was well you should be able to browse down your MNT path into the backup share that you created on your network host:
cd /mnt/server/backup/Backup_CumulusMX
At this point, if you copy a file to the share on that network host, from your Windows PC, you should see it on your Raspberry Pi now (ls -l).
To test permissions are correct on the share, on the Raspberri Pi create a test file:
cd /mnt/server/backup/Backup_CumulusMX
sudo nano test1.txt
Save and exit nono editor, and you should see the file in the share, on the host device. If you got this far, all is well with your mountpoint to the external host
Setup Backups in CumulusMX
Go back to your home drive on the Pi, with cd ~
Then CD into the CumulusMX directory. Edit the CumulusMX config file:
sudo nano cumulusmxsh.conf
Add the cifs share as the backup path:
BACKUPFOLDER= "/mnt/server/backup/Backup_CumulusMX/"
Now you can run quick manual (one off) test backup:
sudo ./cumulusmx.sh -b -t
If this worked ok you should have a TAR backup in your network share, and your good to setup the scheduled task next.
Schedule Automated Nightly Backups
To acheive the automated backups, you'll add a scheduled task to the CRONTAB to do the nightly backups:
sudo crontab –e
if asked, select 'nano' as your editor (easiest)
Insert a new line at the bottom of the crontab file:
00 01 * * * sudo /home/pi/CumulusMX/cumulusmx.sh –b –t >> /dev/null 2>&1
Alt-X, Y to save, Enter to select the filename
This example will backup every night at 1am. By default, the cumulusmx.sh script will keep the last five backups, in a rolling window, so your backup share should never fill over time. You can edit the number of kept backups in the cumulusmxsh.conf file.
Hope this info helps. If I've made any typos or something doesn't like or work right, post below and together we'll work it out.
Cheers for now...
Mark R