Auto backup last n days on an usb stick
This is a simple script which automatically backups files modified in the last n days on a usb stick. It can be run from cron and will require the usb stick to be present only at backup times: <pre lang="bash">#!/bin/bash USB_DEV=/dev/sdb1 MOUNT_POINT=/media/backupusb DAYS=60 SYNC_DIR=/home/tomcat/backup/ find $SYNC_DIR -mtime +$DAYS | sed "s|$SYNC_DIR||" > $SYNC_DIR/exclude mount $USB_DEV $MOUNT_POINT if [ $? -eq 0 ]; then mkdir -p $MOUNT_POINT/backup rsync -rtDxL --safe-links --delete --exclude-from=$SYNC_DIR/exclude --delete-excluded --modify-window=1 -vP $SYNC_DIR $MOUNT_POINT/backup/ umount $MOUNT_POINT else echo Could not mount $USB_DEV on $MOUNT_POINT fi Some explanation on the rsync params:...