Nearly Untouchable automated backup to a 2nd Server


landS

Recommended Posts

** Last Update  2017/12/01 **

TOWER is the primary storage device with SMB shares, some private

TOWER2 is a backup of TOWER, with no SMB/NFS shares.  This also happens to be a lowly D525!

 

Use the Unassigned Devices Plugin to Mount a SMB share to your unRAID Source machine for each source to be backed up.  Set Unassigned Devices settings page SMB share to yes, hidden, fully private.

 

Use the User Scripts Plugin and add 2 scripts which can then be scheduled or run on demand from the plugin 


#Backup script to write once, never update
rsync -r -v --progress --ignore-existing -s /mnt/disks/TOWER_Media/Movies/ /mnt/user/Media/Movies
rsync -r -v --progress --ignore-existing -s /mnt/disks/TOWER_Media/Music/ /mnt/user/Media/Music

 

#Backup to sync all

rsync -av --progress --delete-before /mnt/disks/TOWER_Work/ /mnt/user/Work

rsync -av --progress --delete-before /mnt/disks/TOWER_Docs/ /mnt/user/Docs

 

** Last Update  2016/02/03 **

**Method that follows works, but as of 2017/12/01 is massive overkill**

 

Tower1 contains 2 type of shares for the entire family:

  • A shares are designed as Write Once, read many times (Taxes, Media)
  • B shares are designed as Write/Modify (Work Documents, Homework, etc)

 

Share purpose and back up location:

  • A shares are only backed up to Tower2, A shares are only Read/Write access from a single Windows Machine
  • B shares are backed up to both Tower2 and Crashplan.  B shares have Read/Write mappings to family computers as primary file storage locations (Windows, Mac, Linux, and Android).

 

Tower2 has no SMB.

 

File Loss/Lock Prevention

  • To prevent drag and drop mishaps (mostly due to terrible laptop trackpads), accidental deletion recovery, cryto/ransom lockers, etc.  2 of these 3 are VERY nasty to catch and correct in time... but this should mitigate the problem
  • Recycle Bin deployed on Tower1
  • Crashplan Plugin deployed on Tower2 B Shares
  • A shares initial copy only

 

Pass through Tower2 Shares as mounted Read/Write drives to the VM

Only the VM has Write access to the Tower2 Shares.  The VM has Read only access to the Tower1 shares.

elementaryos-0.3.2-stable-amd64.20151209 VM (Network bridged and on br0)

 

Pass Tower2 Shares through - I will uses share CJK1 as an example

In the VM/KVM Unraid Gui I have the unraid share /mnt/user/CJK1/ with a mount tag as cjk1

Confirmed in XML Expert (no changes made while in Expert)

    <filesystem type='mount' accessmode='passthrough'>
      <source dir='/mnt/user/cjk1/'/>
      <target dir='cjk1'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x03' function='0x0'/>
    </filesystem>
 

 

Start the VM

terminal:

sudo -p mkdir /home/UbuntuUserName/tower2/cjk1
sudo gedit /etc/fstab
 

 

Added to the end:

cjk1   /home/UbuntuUserName/tower2/cjk1      9p      trans=virtio,version=9p2000.L,noauto,nobootwait,rw        0 0
 

 

terminal:

sudo gedit /etc/rc.local
 

 

Added to the end (before exit 0)

mount /home/UbuntuUserName/tower2/cjk1
 

 

[Restart VM]

 

Step 2, rsync away!

Add read only User/Pass to all of the Tower1 shares

 

So, to the terminal:

sudo apt-get install cifs-utils
sudo gedit /etc/nsswitch.conf
 

Change hosts: files mdns4_minimal [NOTFOUND=return] dns

To        hosts: files mdns4_minimal [NOTFOUND=return] wins dns

sudo apt-get install libnss-winbind winbind
 

[reboot vm]

sudo cp /etc/fstab /etc/fstab_old
sudo gedit ~/.smbcredentials
username=UnraidShareUsername
password=UnraidSharePassword
sudo id UbuntuUserName  
     (Note, sudo id is for gid and uid id in the fstab credentials)
sudo gedit /etc/fstab
//192.168.1.155/cjk1 /home/UbuntuUserName/tower/cjk1 cifs credentials=/home/UbuntuUserName/.smbcredentials,iocharset=utf8,gid=1000,uid=1000,file_mode=0777,dir_mode=0777 0 0
sudo mount -a
 

 

A Share Backup (write once, never update)

rsync -r -v --progress --ignore-existing -s /home/UbuntuUserName/tower/writeonce/ /home/UbuntuUserName/tower2/writeonce

 

2017 Update --- permission errors

Run new permissions on the unraid server (select all disks, all shares)

rsync -r -v --no-perms --no-owner --no-group --progress --ignore-existing -s /home/UbuntuUserName/tower/writeonce/ /home/UbuntuUserName/tower2/writeonce

Change /etc/fstab to

//192.168.1.155/cjk1 /home/UbuntuUserName/tower/cjk1 cifs username=ShareUser,password=SharePassword,iocharset=utf8,file_mode=0777,dir_mode=0777

 

B Share Backup (sync all)

rsync -r -v --progress --delete -s /home/UbuntuUserName/tower/cjk1/ /home/UbuntuUserName/tower2/cjk1

 

Step 3, setup the schedule to run Step 2 (script 1) followed by Step 3 (script 2) nightly[/s]

remove -v & --progress from the 2 commands above

 

http://ss64.com/bash/rsync_options.html

 

**

Steps needed

- Confirm rysnc commands work as intended

– Add to Cron scheduler

**

 

 

Edited by landS
Link to comment

If you prefer to do this from a Windows machine mapped to Tower1 and Tower2

Using Notepad save a file called something snappy like backup.bat

 robocopy \\tower\share\folder1 \\tower1\share\folder1 /E /R:0 /W:1
robocopy \\tower\share\folder2 \\tower1\share\folder2 /E /R:0 /W:1
pause 

By swapping /E with /MIR folders/files that are deleted in source will be removed from the destination

 

By adding /IS after /W:1 robocopy will Write once and not update new files

 

to take it 1 step further, save a .BAT file that calls 1.bat, 2.bat, 3.bat, etc

In 1.bat have a single //tower/share1/folder1

in 2.bat have the next //tower/share1/folder2

...etc

This will open up multiple smb scripts allowing (with the additional of Cache Dir), much faster total backups (as the read of new/changed files goes MUCH quicker)

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.