command for deleting backup files after 3 weeks

Status
Not open for further replies.

yyhrzn

Cadet
Joined
Jul 5, 2018
Messages
7
So I created a cronjob for backing up my SMB to a external usb drive (command: rsync -zvr /mnt/files /mnt/Backup/ --delete-after) but I want it to delete the files which were deleted on the SMB only after 3 weeks on the backup drive, not immediately (as in the current command), but I don't know the command for it.

and another question: is there a way to implement a encryption for the backup drive which doesn't stop the backup cronjob from working?

thank you in advance! :)
 
Joined
Dec 29, 2014
Messages
1,135
As a cron job (aka Unix command), it would like this: find /path/to/files/to/be/deleted -type f -mtime +21 -exec rm -f {} \;
 

yyhrzn

Cadet
Joined
Jul 5, 2018
Messages
7
Thank you, but I don't want a specific path to be deleted after 3 weeks. My plan is to backup my FreeNAS SMB to a external drive. When I delete a file on the SMB, i want it to be deleted on the external backup drive too, not immediately, but in 3 weeks.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
If you used a snapshot lifetime of 3 weeks and a replication task to move the data to the backup server, you would get the result you want (in a way...).

Actually what that would do is show the file as deleted immediately in both the production and backup systems, but in fact the snapshot (which would be on both sides) would have the file until it expires in 3 weeks.
 

yyhrzn

Cadet
Joined
Jul 5, 2018
Messages
7
thanks, that'll work for me, but what do i choose as the remote hostname (external backup drive)/port?
 
Last edited by a moderator:

Ericloewe

Server Wrangler
Moderator
Joined
Feb 15, 2014
Messages
20,194
Please do not use external image hosts. Instead, copy/paste your images directly into your message.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
So you'll be setting the server to localhost.

You will want to turn on the options to delete stale snapshots and to replicate children (probably, depends on your structure).

Turn all of the encryption options off or set to none (no point doing this as the data never leaves the server).

You will need to set the SSH key for the root user (or the dedicated user you will use for the job) under that user's settings...

I'm borrowing this text:
Paste the ZFS Replication Public Key to root's SSH Public Key

from this thread (look at @Dusan's first post).
 

fracai

Guru
Joined
Aug 22, 2012
Messages
1,212
seeing as you're using rsync for your backups, I suggest you take a look at "rsnapshot". It will let you create incremental updates and prune old snapshots at whatever interval you want.
rsnapshot.org
 

yyhrzn

Cadet
Joined
Jul 5, 2018
Messages
7
So you'll be setting the server to localhost.

You will want to turn on the options to delete stale snapshots and to replicate children (probably, depends on your structure).

Turn all of the encryption options off or set to none (no point doing this as the data never leaves the server).

You will need to set the SSH key for the root user (or the dedicated user you will use for the job) under that user's settings...

I'm borrowing this text:
Paste the ZFS Replication Public Key to root's SSH Public Key

from this thread (look at @Dusan's first post).

thanks, it's working now! :)
 
Status
Not open for further replies.
Top