<div dir="ltr"><div class="gmail_default" style="font-size:small">Nice, thanks James. If I can get it to run faster, I may use this.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">ed</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 21, 2015 at 1:35 PM, James Sumners <span dir="ltr"><<a href="mailto:james.sumners@gmail.com" target="_blank">james.sumners@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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/)" target="_blank">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" target="_blank">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"><span class=""><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></span><span class="">-- <br><div><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>
</span></div></div></div>
<br>_______________________________________________<br>
Ale mailing list<br>
<a href="mailto:Ale@ale.org">Ale@ale.org</a><br>
<a href="http://mail.ale.org/mailman/listinfo/ale" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
See JOBS, ANNOUNCE and SCHOOLS lists at<br>
<a href="http://mail.ale.org/mailman/listinfo" target="_blank">http://mail.ale.org/mailman/listinfo</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Edward Holcroft | Madsen Kneppers & Associates Inc.<br>11695 Johns Creek Parkway, Suite 250 | Johns Creek, GA 30097<br>O (770) 446-9606 | M (770) 630-0949</div></div>
</div>
<br>
<span style="font-family:arial"><font size="2">MADSEN, KNEPPERS & ASSOCIATES USA, MKA Canada Inc. WARNING/CONFIDENTIALITY NOTICE: This message may be confidential and/or privileged. If you are not the intended recipient, please notify the sender immediately then delete it - you should not copy or use it for any purpose or disclose its content to any other person. Internet communications are not secure. You should scan this message and any attachments for viruses. Any unauthorized use or interception of this e-mail is illegal.</font></span>