Thursday, 9 October 2014

Current backup script...

#!/bin/bash -x
# Name: backup_to_SATA6-C.sh
# Source:
# Purpose:call backup.sh without typing the destination
# Date created: July 16, 2014
# Author: DRC

sudo ./backup.sh /media/chad/SATA6-C/backups/
=========================================

#!/bin/bash
# Name: drc_cleanup
# Source:
# Purpose:Clean Trash Can the easy way
# Date created: June 17, 2014
# Author: DRC
echo "this script is called $0"
echo "this trash cleenup script has been started"

sudo rm -rf /home/chad/.local/share/Trash/files/*

echo "it is done"
echo ""


=========================================

#!/bin/bash

# Name: sudo_backup.sh
# Source: https://wiki.archlinux.org/index.php/Full_system_backup_with_rsync
# from https://wiki.archlinux.org/index.php/Full_system_backup_with_rsync
# Purpose:to backup important system and data files
# Date created: June 17, 2014
# Author: DRC
#
# Notes: must be run by root
# uses drc_cleanup.sh to erase trash first
# uses installed_packages.sh to create an audit file of the backup
#


echo "let us erase the trash can first"
./drc_cleanup.sh

#echo "start script this way: backup.sh /home/chad/.backups"
echo ""

if [ $# -lt 1 ]; then
    echo "No destination defined. Usage: $0 /media/chad/SATA6-C/backups/" >&2
    exit 1
elif [ $# -gt 1 ]; then
    echo "Too many arguments. Usage: $0 destination" >&2
    exit 1
elif [ ! -d "$1" ]; then
   echo "Invalid path: $1" >&2
   exit 1
elif [ ! -w "$1" ]; then
   echo "Directory not writable: $1" >&2
   exit 1
fi

echo "==================================="
echo "this backup script has been started"
echo "==================================="

case "$1" in
  "/home/chad/.backups") ;;
  "/mnt") ;;
  "/mnt/"*) ;;
  "/media") ;;
  "/media/"*) ;;
  "/run/media") ;;
  "/run/media/"*) ;;
  *) echo "Destination not allowed." >&2
     exit 1
     ;;
esac

START=$(date +%s)
rsync -aAXv /* $1 --exclude={/home/chad/.backups/*,/home/chad/Videos/*,/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/var/lib/pacman/sync/*}
FINISH=$(date +%s)
echo "total time: $(( ($FINISH-$START) / 60 )) minutes, $(( ($FINISH-$START) % 60 )) seconds" | tee $1/"Backup from $(date '+%Y-%m-%d, %T, %A')"

echo "let us create an audit file for the backup"
./installed_packages.sh

No comments: