All pastes #133717 Raw Edit

mythbackup script

public text v1 · immutable
#133717 ·published 2006-08-16 02:00 UTC
rendered paste body
#!/bin/sh

# grab timestamp for output files
TIMESTAMP="`date +%m-%d-%y-%H:%M`"

# parent of
MYTHROOT=/usr/local

DATAROOT=/data
BACKROOT=${DATAROOT}/Backups
LOGROOT=${DATAROOT}/Log
LOGFILE=${LOGROOT}/mythbackup.${TIMESTAMP}
PREFIX=mythinstall
BACKFILE="${PREFIX}.${TIMESTAMP}"

# Start logging
{

( cd ${MYTHROOT}; tar cvf - myth ) | ( cd ${BACKROOT} ; gzip -c > ${BACKFILE} )

# kill backups older than a week
echo "Removing files:" >> ${LOGFILE}
cd ${BACKROOT}
find . -mtime +7 -maxdepth 1 -type f -name ${PREFIX}\* -print -exec rm \{} \;

} > ${LOGFILE} 2>&1