From owner-freebsd-questions@FreeBSD.ORG Fri May 30 06:33:24 2014 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B77E19C0 for ; Fri, 30 May 2014 06:33:24 +0000 (UTC) Received: from mail-pd0-x229.google.com (mail-pd0-x229.google.com [IPv6:2607:f8b0:400e:c02::229]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8ED73246B for ; Fri, 30 May 2014 06:33:24 +0000 (UTC) Received: by mail-pd0-f169.google.com with SMTP id w10so618171pde.28 for ; Thu, 29 May 2014 23:33:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=M2F84v4eDDIooM8ZG17mI0KWCBGHmrkBfORdzwVXrbk=; b=xEoG3Vcjh3yk+S8ICbh43QZECJXoYco35fNWw+pxLTw6WzLYbdCfgW1U3OCFzA9AJ6 7BLGdsYFiP4J8Lr94WrMXOHq/0Y4V9zSZ6/ftEuPCm3bcgJd5JqV+p08o5sCCUC+B0BE GdMfXkPXAU5o994c47XlMlHbuhJ2j/fzeVLhvSae3Dab7av273LG+tmJdTNWW2vuSxLT crr2v2qvM9alolNilN5vVnPS8i2QJ9yRXOB5tKSsJtQvoGXKtgJasl6EqqVc/azHPcAJ HARb0bzJQKfVF3FtS0435IaVZRs/GIUg2OSAKpWYszK9AipwsgPCtOqXCdUehrcjkuiB EGlQ== X-Received: by 10.68.213.74 with SMTP id nq10mr15865926pbc.4.1401431604113; Thu, 29 May 2014 23:33:24 -0700 (PDT) Received: from SergeiMBP.local ([2601:8:a880:fd6:345b:ad9a:bf5a:fe13]) by mx.google.com with ESMTPSA id bu3sm13921613pac.28.2014.05.29.23.33.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 May 2014 23:33:23 -0700 (PDT) Message-ID: <53882631.10604@gmail.com> Date: Thu, 29 May 2014 23:33:21 -0700 From: Sergei G User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: FreeBSD Questions Subject: Request for review of pax based periodic backup setup Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 May 2014 06:33:24 -0000 I created the following backup script based on periodic functionality: cat /usr/local/sbin/periodic-backup.sh #!/bin/sh # # If there is a global system configuration file, suck it in. if [ -r /etc/defaults/periodic.conf ] then . /etc/defaults/periodic.conf source_periodic_confs fi # load configuration arguments is_enabled_name=${1:-daily_backup_usr_local_enable} # conf file is expected to have one directory or file per line # empty lines are ok # comments sart with # conf_file=${2:-/usr/local/etc/backup-usr-local.conf} out_file=${3:-/var/backups/usr-local.pax} # can be used to pass argument u to write updated files only, instead of all by default pax_arg=${4:-} eval is_enabled=\${$is_enabled_name} case "$is_enabled" in [Yy][Ee][Ss]) if [ ! -f ${conf_file} ] then echo "${is_enabled_name} is set, but ${conf_file} doesn't exist" rc=2 else echo "" echo "Running backup to ${out_file} with ${conf_file}, pax_arg '${pax_arg}':" grep -v -e ^# -e '^[[:space:]]*$' ${conf_file} | pax -w${pax_arg}f ${out_file} && rc=0 || rc=3 fi;; *) rc=0;; esac exit $rc ----end of file----- I then created a simple periodic script: cat /usr/local/etc/periodic/daily/603.backup_usr_local #!/bin/sh # 1 - /usr/periodic.conf variable name # 2 - configuration file name # 3 - output pax file # 4 - update mode (optional) /usr/local/sbin/periodic-backup.sh daily_backup_usr_local_enable /usr/local/etc/backup-usr-local.conf /var/backups/usr-local.pax u ---end of file--- This allows me to control multiple pax files/destinations. Sample config file: cat /usr/local/etc/backup-usr-local.conf # list files and directories to backup /usr/local/bin/ /usr/local/git/ ---end of output--- What do you think? Thanks