Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Jan 2016 02:25:03 -0800
From:      Sergei G <sergeig.public@gmail.com>
To:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   rolling backup
Message-ID:  <56A5F7FF.1050606@gmail.com>

next in thread | raw e-mail | index | archive | help
Is there any good application for maintaining a rolling backup of 
filesystem?

I wrote this simple Makefile that's called from a periodic scripts to 
maintain backups.  However, over time it will run out of space. The 
solution would be to have the same backup reusing file names using a 
rolling backup scheme.  Is there a project that can do that already?

In rolling backup I would be using parts of the date output (date -j 
+"%Y-%m-%d %H:%M:%S") and a mod operation to roll the number.  I just 
don't have time to spend on it...


Thanks

Script I use:
----------


# Dump Options
# -C32 is a cash in MB for snapthot based filesystems.  Range is 0..32
# -b128 is number of KB per output block.  It improves performance.
# -0 is a full backup
# -u update dump dates after successful dump
# -n notify all operators in operator group
# -a autosize is used for harddrives and other non-tape media
# -L is a live file system; use /.snap directory
# -h1 honor no_dump flag for backup level at or above specified number
# -f file_name is write backup to a file_name; use - for STDOUT
#
# return values:
# 0 - ok
# 1 - startup errors
# 3 - abnormal termination

dump=/sbin/dump
level=0
dumpargs=-C16 -b128 -$(level)unaL -h1 -f -
dumpcmd=$(dump) $(dumpargs)

bzip2=/usr/bin/bzip2
bzip2args=--best
compress=$(bzip2) $(bzip2args)

expr=/bin/expr
now=`date +%Y-%m-%d`
backupdir=/backup
suffix=$(now)_$(level).dump.bz2

default:
         @cat dump.mak

test:
         @echo level:    $(level)
         @echo dumpargs: $(dumpargs)
         @echo compress: $(compress)
         @echo dumpcmd:  $(dumpcmd)

# http://milan.adamovsky.com/2010/06/freebsd-makefile-local-variables.html
# .ifmake target
# SOMEVAR=1
# .endif

run:
         @echo Backing up /
         $(dumpcmd) /            | $(compress) > $(backupdir)/root_$(suffix)

         @echo Backing up /var
         $(dumpcmd) /var         | $(compress) > $(backupdir)/var_$(suffix)

         @echo Backing up /usr
         $(dumpcmd) /usr         | $(compress) > $(backupdir)/usr_$(suffix)

         @echo Backing up /usr/jails
         $(dumpcmd) /usr/jails   | $(compress) > 
$(backupdir)/jails_$(suffix)




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?56A5F7FF.1050606>