Easy way of making copies of a folder, there has to be some easy way to do this!

John Falk

Dabbler
Joined
Nov 26, 2022
Messages
10
I've moved from using an Asustor NAS to TrueNAS Core. Mainly because the Asustor wasn't very quick and I had a complete PC in pieces laying around (Core i5 7600, 32GB RAM, SSD for the OS installation and two WD Red 2TB for the storage pool) that I could set up to run TrueNAS. It works really well, but now when I want to do some more advanced things I get lost in options, and when I read about it I just get more lost.

I want my Documents folder on my Windows PC backed up automatically in real-time. I have solved that with FreeFileSync. I created a batch file and run it in RealTimeSync. It works as I want it to. I backup my Documents folder to a folder on the NAS /mnt/Tank/Shares/Backups/Deep Thought/Documents/1-Realtime

I want that folder copied to /mnt/Tank/Shares/Backups/Deep Thought/Documents/2-Daily and to /mnt/Tank/Shares/Backups/Deep Thought/Documents/3-Weekly
The 2-Daily folder should be the files in 1-Realtime copied at midnight every day and 3-Weekly should be the files in 1-Realtime copied every Sunday.
There has to be some easy way to do this!
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Sounds like a couple of Rsync tasks would do it.
 

John Falk

Dabbler
Joined
Nov 26, 2022
Messages
10
I've been fiddling with Rsync but I'm getting nowhere. Where do I do that and how?
 

John Falk

Dabbler
Joined
Nov 26, 2022
Messages
10
I found this: https://clubmate.fi/sync-large-quat...s-between-local-machine-and-server-with-rsync

Would this work?: rsync -zaP --delete /mnt/Tank/Shares/Backups/Deep Thought/Documents/1-Realtime /mnt/Tank/Shares/Backups/Deep Thought/Documents/2-Daily

Do I need to enable SSH? I tried that but got stuck on the private key, I'm just a total noob, sorry.
I want it to run this on a schedule, where do I add do that? There are so many options so I get lost.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Do I need to enable SSH?
Not for a local rsync.

I want it to run this on a schedule, where do I add do that? There are so many options so I get lost.

If you just want to run a command at a time, a cron job is what you would use. (Tasks | Cron Jobs on the left menu)

The command you quoted has spaces in the path, so you need to escape those or put quotes around the whole path.

Like this:
rsync -zaP --delete /mnt/Tank/Shares/Backups/Deep\ Thought/Documents/1-Realtime /mnt/Tank/Shares/Backups/Deep\ Thought/Documents/2-Daily
or this:
rsync -zaP --delete "/mnt/Tank/Shares/Backups/Deep Thought/Documents/1-Realtime" "/mnt/Tank/Shares/Backups/Deep Thought/Documents/2-Daily"

You should play around with getting it to work in the shell first to the point you're happy, then start looking at the cron job (which will likely need the full path to rsync to launch correctly)

Like this:
/usr/local/bin/rsync -zaP --delete /mnt/Tank/Shares/Backups/Deep\ Thought/Documents/1-Realtime /mnt/Tank/Shares/Backups/Deep\ Thought/Documents/2-Daily
 
Last edited:

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
You could, of course, just run a snapshot task every day and set the retention to a week or however long you want and be able to go back to those snapshots at your leisure without the need to copy at all.
 

Arwen

MVP
Joined
May 17, 2014
Messages
3,611
I second @sretalla's comment about using snapshots. Your use case sounds like the exact purpose of ZFS snapshots.

The nice thing about ZFS snapshots is they take only enough space to account for the differences, (and a bit of overhead). So a 1GB change daily on a 100GB used ZFS Dataset, over 1 week, would only use about 107GBs. Unlike a full daily copy of 100GBs, which over a week would be 700GBs.

ZFS snapshots can be:
  • Accessed if a prior version of a file is needed
  • Rolled back to specific snapshot, throwing away recent changes if desired.
ZFS snapshots DON'T recover file updates made after the most recent snapshot, that the file is then updated again or deleted. This is why some people have hourly snapshots kept for 1 day. Still not perfect, but it's better than what came before.
 

John Falk

Dabbler
Joined
Nov 26, 2022
Messages
10
I had completely missed reading up and understanding Rsync Modules. Once I did it was easy to create Rsync Tasks for daily, weekly and monthly copies of the folder. I want that many versions because I make music on that computer and store all the mixes and recordings in the Documents folder. It's saved my ass a couple of times to be able to recall a mix from yesterday, or even a week ago sometimes. Thanks to everyone who answered my question! I'm going to have a look at your solutions too, just to learn more about TrueNAS.
 

Arwen

MVP
Joined
May 17, 2014
Messages
3,611
@John Falk - Glad you now have a solution.

One thing I would advise is to test it regularly. Maybe in the beginning every few days. Next, once a week a few times. Then permanently once a month. Backups un-tested / un-verified may be a warm fuzzy feeling, but transition to panic if the backups are not doing their job when you NEED them.

A second thing I would advise, if using RSync, make the destination(s) separate datasets. You can then change their attributes if desired. Though, if you are sharing out via SMB or NFS, this could be too much work.
 
Top