Backup on NAS share

Hi
I search good solution script to backup all configuration to share NAS directory. As it is solution to backup on USB drive. Please help me…
Thanks

This is for a raspberry pi. This shouldn’t be too much different if you are running linux though. What I did was mount the NAS folder I wanted to backup into onto the raspberry pi. I then created a script that uses rsync to copy the contents of / to the mounted folder. I then created a cron job to run my script once a week.

I don’t remember the exact command but I have a link embedded in the script that I can post here if you would like. I opted for rsync instead of a system image because it will be quicker since it only has to update files that have changed. I know there is better ways to do this such as using gzip or something, but since my sd card is only 8 gigs I’m not too worried about space.

Can you give me step by step full manual how configure it ?

I have this script for Pi, basically mount the samba share to /media/usb, rsync, umount:

#!/bin/bash>
sudo mount -t cifs //IP of NAS/shared_folder /media/usb -o user=username,pass=password
sudo rsync -rltzuv /path_to_be_backup /media/usb/backup_folder
sudo umount /media/usb

But i must any install app ?

This is what I used for rsync. This isn’t exactly what I used to setup the mount drive because I didn’t save it but it should work. You should be able to skip the “Setting up the Server” section if you already have the NAS sharing an NFS folder. The only change I would make there is to mount it to /mnt instead of /srv.

  1. Create a folder on your raspberry pi to mount the NFS drive to. I did /mnt/backup.
  2. Mount the drive with the command line first. This is done with “sudo mount nasIp:/path/on/nas /mnt/backup”
  3. Ensure the drive is connected by creating a file in /mnt/backup. This could be done through the GUI or with “touch /mnt/backup/test.txt”
  4. Edit /etc/fstab by appending “nasIp:/path/on/nas /mnt/backup nfs default 0 0” to the end.
  5. That is the directions for the second article.
  6. Create the rsync-exclude.txt file with the contents explained in the first link.
  7. Create a script called “backup.sh” with the contents of
#! /bin/bash
rsync -aHv --delete-during --exclude-from=/rsync-exclude.txt / /mnt/backup/
  1. Run this to make sure it works. It should take quite a bit of time as it copies over everything.
  2. Run “crontab -e” and add the following to the end of the file
0 3 * * 1 /path/to/backup.sh

That will create a cron job that will run every Sunday at 3 am to backup your whole hard drive/SD card to the NAS drive.

1 Like