Project

General

Profile

Download (980 Bytes) Statistics
| Branch: | Tag: | Revision:
1
#!/bin/sh
2
# Script which lists the backups present on a server
3
###########################################################################
4

    
5
. ${PROGDIR}/backend/functions.sh
6

    
7
SSHUSER=$1
8
SSHHOST=$2
9
SSHPORT=$3
10

    
11
if [ -z "${SSHHOST}" -o -z "${SSHPORT}" ]
12
then
13
  echo "ERROR: Usage list-rsync-backups.sh <user> <host> <port>"
14
  exit 150
15
fi
16

    
17
# Look for full-system backups, needs at minimum a kernel to be bootable
18
FINDCMD="find . -type d -maxdepth 6 -name 'kernel' | grep '/boot/kernel'"
19

    
20
# Get a listing of the number of full backups saved
21
OLDBACKUPS=`ssh -o 'BatchMode=yes' -p ${SSHPORT} ${SSHUSER}@${SSHHOST} "${FINDCMD}"`
22
if [ "$?" = "0" ]
23
then
24
  for i in ${OLDBACKUPS}
25
  do
26
    BACKPATH="`echo ${i} | sed 's|/boot/.*||g' | sed 's|^./||g'`"
27
    if [ -z "${BACKLIST}" ]
28
    then
29
      BACKLIST="${BACKPATH}"
30
    else
31
      BACKLIST="${BACKLIST}:${BACKPATH}"
32
    fi
33
  done
34

    
35
  if [ -z "${BACKLIST}" ]
36
  then
37
    echo "NONE"
38
  else
39
    echo "$BACKLIST"
40
  fi
41

    
42
else
43
  echo "FAILED"  
44
fi
(9-9/20)