aboutsummaryrefslogtreecommitdiff
path: root/templates/rsync-check.sh.erb
blob: a33606d0a97d27ea96bfdeed82a9b69e20399472 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
#
# Check rsync backup sets.
#

BACKUP_FOLDER="<%= backupdir_remote %>"

if [ -e "$BACKUP_FOLDER" ]; then
  cwd="`pwd`"
  cd $BACKUP_FOLDER

  for set in `find -maxdepth 2 -name 'rsync'`; do
    created="`find $set -name 'created' 2> /dev/null | sort`"
    rotated="`find $set -name 'rotated' 2> /dev/null | sort`"

    if [ ! -z "$created" ] || [ -d "$set/<%= backupdir %>/duplicity" ]; then
      echo " "
      echo "Checking backup set $set..."
      echo "======================================================"
      echo " "
    fi

    # Check rsync metadata
    if [ ! -z "$created" ]; then
      echo " "
      echo "Available dates"
      echo "======================================================"
      echo " "
      for metadata in $created; do
        echo -n "$(basename `dirname $metadata`): created at "
        head -1 $metadata
      done

      for metadata in $rotated; do
        echo -n "$(basename `dirname $metadata`): rotated at "
        head -1 $metadata
      done
    fi

    # Check duplicity metadata
    if [ -d "$set/<%= backupdir %>/duplicity" ] && [ "$1" != "--short" ]; then
      for duplicity in `ls -1 $set/<%= backupdir %>/duplicity | grep -v metadata | xargs`; do
        echo " "
        echo "Checking duplicity backup found at $set/<%= backupdir %>/duplicity/$duplicity..."
        echo "======================================================"
        echo " "
        duplicity collection-status file:///$BACKUP_FOLDER/$set/<%= backupdir %>/duplicity/$duplicity
      done
    fi
  done
  
  cd $cwd
fi