New to FreeNAS, need help

Status
Not open for further replies.

Sadmin

Cadet
Joined
Feb 27, 2018
Messages
2
Hi,

I'm new into FreeNAS, i have question for you guys.
My predecessor was in command of our backup, he made code line like this (in cron jobs) :
Code:
cp /data/freenas-v1.db /mnt/zew_backup/config_backup/`date \+%Y\%m\%d`_`cat /etc/version | cut -d'-' -f2`_`cat /etc/version | cut -d'-' -f4`.db 

It is working very well, but from last week i need to delete backups older than 7 days by hand (by mouse click to be specific), is there a way to make another cron job for a script to do the work?

Regards
 
Last edited by a moderator:

Nick2253

Wizard
Joined
Apr 21, 2014
Messages
1,633
it is working very well, but from last week i need to delete backups older than 7 days by hand (by mouse click to be specific), is there a way to make another corn job to script do the work?
Is there a reason you want to delete old backups? The config file takes up only a tiny amount of space, and even a decade's worth of daily backups would be under a GB.
 

Sadmin

Cadet
Joined
Feb 27, 2018
Messages
2
The reason is that some of backup are using more than 20 MB/day, so with bunch of users, you get a lot of used space...
we have not so big disk space, and management does not want to buy extra disks, so we have to delete older snapshots.
 
Last edited by a moderator:

m0nkey_

MVP
Joined
Oct 27, 2015
Messages
2,739
I wrote this for myself. I only backup once a week since there are very few config changes. I keep the last 4 backups. I strongly suggest you test this script thoroughly with your set-up before putting it into production.
Code:
#!/bin/sh

HOSTNAME=$(hostname)
DATE=$(date +%Y-%m-%d)
DESTDIR="/mnt/tank/opt/config"

NUM_OF_BACKUPS="4"

cp /data/freenas-v1.db ${DESTDIR}/FreeNAS-${HOSTNAME}-${DATE}.db

CONF_FILE=`ls -b ${DESTDIR}/*.db | sort -r`

COUNT=0
for FILE in ${CONF_FILE}; do
		COUNT=`expr ${COUNT} + 1`
		if [ ${COUNT} -gt ${NUM_OF_BACKUPS} ]; then
				rm -f ${FILE}
		fi
done

Here's whats in my config/ directory:
Code:
[root@tardis] /mnt/tank/opt/config# ls -b *.db | sort -r
FreeNAS-tardis.localnet-2018-02-23.db
FreeNAS-tardis.localnet-2018-02-16.db
FreeNAS-tardis.localnet-2018-02-09.db
FreeNAS-tardis.localnet-2018-02-02.db
[root@tardis] /mnt/tank/opt/config#
 

Nick2253

Wizard
Joined
Apr 21, 2014
Messages
1,633
The reason is that some of backup are using more than 20 MB/day, so with bunch of users, you get a lot of used space...
we have not so big disk space, and menagement don't want to buy extra disks, so we have to delete older snapshots.
The config file backup is not a snapshot.

It's very possible that you have automatic snapshots configured, and those are what are using the space. Again, the config file should be tiny, and if it's taking up 20MB, something's wrong (my config backup is 300KB).

I would check your snapshots, and see what's going on there. You might need to decrease your snapshot retention window.
 
Status
Not open for further replies.
Top