<div dir="ltr">I use the script included in this email to run backups. It's really just a call to duplicity after some sanity checks. Run on a system that hasn't been backed up before, where that system is about 1.7GB of data, it takes about 8 minutes to run.<div><br></div><div>````</div><div><div>#!/bin/bash</div><div> </div><div># Pre-execution check for bsfl</div><div># Set options afterward</div><div>if [ ! -f /etc/bsfl ]; then</div><div> echo "Backup script requires bsfl (<a href="https://code.google.com/p/bsfl/)">https://code.google.com/p/bsfl/)</a>."</div><div> exit 1</div><div>fi</div><div>source /etc/bsfl</div><div> </div><div>### Options ###</div><div> </div><div># Set to the desired logfile path and name</div><div>LOG_FILE="$(dirname $0)/logs/runbackup-$(date +'%m-%d-%Y').log"</div><div> </div><div># Set to the file that contains backup exclusions (format = line separated paths)</div><div>EXCLUDES="$(dirname $0)/excludes"</div><div> </div><div># Set to the NFS mount point</div><div># Be sure to configure /etc/fstab appropriately</div><div>NFS_DIR="$(dirname $0)/remote"</div><div> </div><div># Set to test string for testing NFS mount success</div><div>NFS_MOUNT_TEST="^//bigspace.*/this_system_dn"</div><div> </div><div># Set to the remote backup container directory</div><div># Backups will be stored in subdirectories of this directory</div><div>BACKUP_DIR="${NFS_DIR}"</div><div> </div><div># Set to the email address that will receive notifications</div><div># of backup failures</div><div>ERROR_EMAIL_ADDR="<a href="mailto:admin@example.com">admin@example.com</a>"</div><div> </div><div># Set to the list of switches you want passed to Duplicity</div><div># Add '--time-separator .' if using an old version of Duplicity</div><div>DUPLICITY_SWITCHES="-v4 --no-encryption --exclude-globbing-filelist ${EXCLUDES} --exclude-other-filesystems --volsize 150 --full-if-older-than 30D"</div><div> </div><div> </div><div>### Begin actual script ###</div><div> </div><div>function notify {</div><div> mail -s "Backup failure on $(hostname)" ${ERROR_EMAIL_ADDR} < ${LOG_FILE}</div><div>}</div><div> </div><div># Turn on bsfl logging support</div><div>LOG_ENABLED="yes"</div><div> </div><div># We need to be root to 1) read all files and 2) mount the NFS</div><div>USER=$(whoami)</div><div>if [ "${USER}" != "root" ]; then</div><div> notify</div><div> die 2 "Backup must be run as root."</div><div>fi</div><div> </div><div>log "Mounting NFS"</div><div>mount ${NFS_DIR}</div><div> </div><div>NFS_MOUNTED=$(cat /proc/mounts | grep ${NFS_MOUNT_TEST})</div><div>if [ ! $? -eq 0 ]; then</div><div> notify</div><div> umount ${NFS_DIR}</div><div> die 3 "Could not mount remote share."</div><div>fi</div><div> </div><div># Let's make sure we have enough room on the remote system</div><div>STAT_INFO=$(stat -f --format='%b %a %S' ${NFS_DIR})</div><div>TOTAL_BLOCKS=$(echo ${STAT_INFO} | awk '{print $1}')</div><div>FREE_BLOCKS=$(echo ${STAT_INFO} | awk '{print $2}')</div><div>BLOCK_SIZE=$(echo ${STAT_INFO} | awk '{print $3}')</div><div># (1024bytes * 1024kilobytes) / (x bytes) = (1 megabyte [in bytes]) / (x bytes)</div><div># => number of blocks in 1 megabyte = y</div><div>REMOTE_FREE_BYTES=$(echo "${FREE_BLOCKS} / (1048576 / ${BLOCK_SIZE})" | bc -l)</div><div>log "Remote free bytes = ${REMOTE_FREE_BYTES}"</div><div> </div><div>STAT_INFO=$(stat -f --format='%b %a %S' /)</div><div>TOTAL_BLOCKS=$(echo ${STAT_INFO} | awk '{print $1}')</div><div>FREE_BLOCKS=$(echo ${STAT_INFO} | awk '{print $2}')</div><div>BLOCK_SIZE=$(echo ${STAT_INFO} | awk '{print $3}')</div><div>LOCAL_USED_BYTES=$(echo "(${TOTAL_BLOCKS} - ${FREE_BLOCKS}) / (1048576 / ${BLOCK_SIZE})" | bc -l)</div><div>log "Local used bytes = ${LOCAL_USED_BYTES}"</div><div> </div><div>REMOTE_HAS_ROOM=$(echo "${REMOTE_FREE_BYTES} > ${LOCAL_USED_BYTES}" | bc -l)</div><div>if [ ${REMOTE_HAS_ROOM} -eq 0 ]; then</div><div> log_error "Remote system does not have enough free space for the backup."</div><div> notify</div><div> umount ${NFS_DIR}</div><div> die 4 "Remote system does not have enough free space for the backup."</div><div>else</div><div> log "Remote system has enough room. Proceeding with backup."</div><div> log "===== ===== ===== ====="</div><div> log ""</div><div>fi</div><div> </div><div># Send today's delta over</div><div>duplicity ${DUPLICITY_SWITCHES} / file://${BACKUP_DIR} 2>&1 1>>${LOG_FILE}</div><div> </div><div># Remove unnecessary data over 6 days old</div><div>duplicity remove-older-than 6D --force ${DUPLICITY_SWITCHES} file://${BACKUP_DIR} 2>&1 1>>${LOG_FILE}</div><div> </div><div>log ""</div><div>log "===== ===== ===== ====="</div><div>log "Backup complete."</div><div> </div><div>umount ${NFS_DIR}</div></div><div>````<br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 21, 2015 at 1:21 PM, Edward Holcroft <span dir="ltr"><<a href="mailto:eholcroft@mkainc.com" target="_blank">eholcroft@mkainc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div style="font-size:small">I'm trying without encryption. It still seems the same, not constant hard drive i/o going on. Will let it run for a while and see what happens.</div><div style="font-size:small"><br></div><div style="font-size:small">ed</div></div></blockquote></div><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>James Sumners<br><a href="http://james.sumners.info/" target="_blank">http://james.sumners.info/</a> (technical profile)</div><div><a href="http://jrfom.com/" target="_blank">http://jrfom.com/</a> (personal site)</div><div><a href="http://haplo.bandcamp.com/" target="_blank">http://haplo.bandcamp.com/</a> (band page)</div></div></div></div></div>
</div></div></div>