backup script

Status
Not open for further replies.

dejv

Dabbler
Joined
Aug 28, 2016
Messages
39
I installed freenas 11 together with nextcloud 10

I wish to create a script that compresses the folder data of nextcloud ( /mnt/Live/jails/nextcloud_1/media) and the compressed file is aved to /mnt/Backups/NextCloud Backups
The file name should be according to the date of when the backup was executed.

Then on the 6th day the backup is deleted.

Any ideas if this can be done ?
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
If you only plan on keeping the data for 6 days it seems a snapshot task would be a better route to accomplish this.
 

dejv

Dabbler
Joined
Aug 28, 2016
Messages
39
thanks for the quick reply. But isn't a snapshot kept on same disks ? the folder where my folders will be backed up are a separate hard drives

Also when using a snapshot, you only can restore all the snapshot on the live data. You cannot restore a particular folder that was deleted am I right ?
 
Last edited:

IceBoosteR

Guru
Joined
Sep 27, 2016
Messages
503
Hi,
yes you are right, the snapshots are located on the same disks as the data.
A snapshot is a 1:1 copy of the data to the point of time where the snapshot has been taken. This includes all files and folders. You can restore particular files with a Windows Share, and with "recent versions" you are able to see and restore that data.
 

dejv

Dabbler
Joined
Aug 28, 2016
Messages
39
I would prefair having the backup on a seperate disks just in case something happens to the live disks :S that is why I chose of backing up the files using a script.
 

IceBoosteR

Guru
Joined
Sep 27, 2016
Messages
503
I would prefair having the backup on a seperate disks just in case something happens to the live disks :S that is why I chose of backing up the files using a script.
Are you familar with scripting in bash or ksh?
 

Pitfrr

Wizard
Joined
Feb 10, 2014
Messages
1,531
And what about a combination of snapshots, replication on an other machine (and then compress it there? No clue if this is possible though... ;-O).
 

dejv

Dabbler
Joined
Aug 28, 2016
Messages
39
Are you familar with scripting in bash or ksh?

No but if I find one one the net I am able to understand and amend it

Currently I am trying to use this command manually to check the syntax before transferring to a script but I am stuck with an error

Code:
 tar -zcf mnt/Live/jails/nextcloud_1/media/test.tar.gz mnt/Backups/NextCloud_Backups


tar: Failed to clean up compressor
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
You can clone a snapshot to recover individual files. If someone hasnt replied to help ill reply later when im at home with a backup script i use in one of my jails. It just does a backup but does not prune them.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
But isn't a snapshot kept on same disks ?
Yes, until you set up a replication task to put it on another pool.
You cannot restore a particular folder that was deleted am I right ?
Not really. First, as @Jailer said, you can clone the snapshot (rather than rolling back), creating a separate copy of its contents. Second, within any dataset, you can navigate to .zfs/snapshot/(snapshot name) and see (and copy) files in the snapshot.
 

dejv

Dabbler
Joined
Aug 28, 2016
Messages
39
thanks for the reply. can the replication task be automated ?
Also say if I have 100gb data and I take a snapshot, the first snapshot will be 100gb and then the ones after that will be depending on the changes done to the files ?

If so the hard drives will be less stressed during rather than compressing all data everyday.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504

dejv

Dabbler
Joined
Aug 28, 2016
Messages
39
Currently on my system I have 2 zfs one for live and one for backups.

I setup the snapshot successfully. However is there a way to replicate the snapshots on the same system as on the same system? as on all the tutorials I found they all specify a remote system :S
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Just specify "localhost" as the name of the remote system. Local replication is far more complicated than it should be, and the devs haven't shown any interest in improving it. (see https://bugs.freenas.org/issues/23784, for example)
 
Status
Not open for further replies.
Top