aboutsummaryrefslogtreecommitdiff
path: root/templates/rsync-check.sh.erb
blob: aa1a19c796c7daa23549500f737cc4ceb2a19bfb (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
#!/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
    metadatas="`find $set -name 'created' 2> /dev/null`"

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

    # Check rsync metadata
    if [ ! -z "$metadatas" ]; then
      echo " "
      echo "Available dates"
      echo "======================================================"
      echo " "
      for metadata in $metadatas; do
        cat $metadata
      done
    fi

    # Check duplicity metadata
    if [ -d "$set/<%= backupdir %>/duplicity" ]; 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