12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #! /bin/sh
- FTP_SERVER=backup.serverkompetenz.de
- BAK_PATH=backup/full
- BAK=$1
- if [ -z ${BAK} ]; then
- echo "USAGE: `basename $0` BAK_DIR" >&2
- exit 1
- fi
- set -A FILES `/usr/local/bin/curl -s -n -l "ftp://${FTP_SERVER}/${BAK_PATH}/${BAK}/" \
- | grep -v '^\.' | grep -v '\.gz$' | grep -v '\-0$'`
- let RESULT=$?
- if [ ${RESULT} != 0 ]; then
- echo "curl returned ${RESULT}"
- exit 2
- fi
- let IDX=0
- (
- cat <<-EOF
- open ${FTP_SERVER}
- cd "${BAK_PATH}/${BAK}/"
- prompt
- EOF
- while [ ${IDX} -lt ${#FILES[@]} ]; do
- FNAME=${FILES[IDX]}
- echo "del ${FNAME}"
- IDX=$((IDX + 1))
- done
- echo 'close'
- ) | ftp
- let RESULT=$?
- if [ ${RESULT} != 0 ]; then
- echo "ftp returned ${RESULT}"
- exit 3
- fi
- exit 0
|