• Welcome to SAIL Community Supported PBX . Please login or sign up.
 
May 05, 2024, 11:01:54 AM

News:

SMF updated to 2.0


Simple NAS backup

Started by davidiwharper, April 27, 2017, 06:32:45 PM

Previous topic - Next topic

davidiwharper

This is a short tutorial about backing up SAIL to a NAS drive over NFS. I've used a QNAP NAS as the example.

1. First, we'll need to turn on NFS on the QNAP and enable NFS access for the specific share you'll be using. The instructions will vary by device and firmware version, but you can get the idea at http://docs.qnap.com/nas/4.3/cat2/en/win_mac_nfs.htm and http://docs.qnap.com/nas/4.3/cat2/en/file_station.htm. I recommend you create an ACL which permits access only from the specific SAIL host.
2. Now we can add the mount point on the SAIL server and set up NFS access. To begin, let's create the mountpoint used by the backup manager tool:

sudo mkdir /var/archives

3. Now we can test that the NFS mounting works. Replace 10.0.0.20 with the IP address of your NAS device, and pbx_backup with the share you created in Step 1:

sudo mount -t nfs 10.0.0.20:/pbx_backup /var/archives

4. Let's test write access:

sudo touch /var/archives/testfile

You can now browse your NAS share from elsewhere and check that the file is present.
5. If mounting and writing works, it's time to add the NFS share to your /etc/fstab so it's automatically mounted on boot.

sudo nano /etc/fstab

Let's add the following to the file:

# NAS1 backup
10.0.0.20:/pbx_backup   /var/archives  nfs     defaults        0       0

6. Reboot the server and repeat the test from step 4.
7. Now we can install backup-manager, the simple tool we will be using to handle the backups:

sudo apt-get install backup-manager backup-manager-doc

When prompted for locations to backup, you can keep the default folders (/etc and /home), and add the following: /opt/sark/db /var/spool/asterisk /opt/sark/bkup /opt/sark/snap
8. We now need to disable SCP upload, which is enabled by default. This is done from the /etc/backup-manager.conf file. As this is pretty big, we'll figure out what line we need to edit in advance:

sudo grep -n scp /etc/backup-manager.conf

We can then go straight to that line with nano (replace 300 with the output from grep -n)

sudo nano +300 /etc/backup-manager.conf

We can now change the "BM_UPLOAD_METHOD" to "none" by modifying the line as follows:

export BM_UPLOAD_METHOD="none"

9. Time to test the backup! Run the following command:

sudo backup-manager

You should see a number of .tar.gz files on your NAS share straight away.
10. Finally, we can automatically back up our system every day by adding the backup-manager command to /etc/crontab, the system scheduler's control file. First, let's open it up:

sudo nano /etc/crontab

Now add the following lines at the bottom of the file:

# backup
0 21 * * * root /usr/sbin/backup-manager >/dev/null 2>&1

Save the file and you're done!