fullftpdump 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/sh
  2. FTP_SERVER=backup.serverkompetenz.de
  3. DIRNAME=`date +%Y-%m`
  4. FILEDATE=`date +%Y-%m-%d`
  5. BACKUPPATH="backup/full/${DIRNAME}"
  6. # Check that the .dumppartitions file is available
  7. if [ ! -e ${HOME}/.dumppartitions ]; then
  8. echo "$0: The config file .dumppartitions not found in \$HOME"
  9. exit 4
  10. fi
  11. # Get the paths to the used commands that are not in base
  12. NCFTPPUT=`whereis ncftpput`
  13. if [ -z ${NCFTPPUT} ]; then
  14. echo "$0: Unable to find command ncftpput"
  15. exit 3
  16. fi
  17. ARGS=`getopt l: $*`
  18. if [ $? -ne 0 ]; then
  19. echo "Usage: $0 -ln"
  20. echo "\t-l n\tWhere n is the dumplevel"
  21. exit 2
  22. fi
  23. # Set 0 as the default dump level
  24. LEVEL=0
  25. set -- ${ARGS}
  26. while [ $# -ge 0 ]; do
  27. case "$1"
  28. in
  29. -l)
  30. LEVEL="$2"; shift; shift
  31. ;;
  32. --)
  33. shift; break
  34. ;;
  35. esac
  36. done
  37. LEVEL=$((LEVEL + 0))
  38. #echo $LEVEL
  39. # Create the dump directory on the ftp server
  40. # TODO: Create the directory recursivly
  41. /usr/bin/ftp <<-EOF
  42. open ${FTP_SERVER}
  43. epsv
  44. binary
  45. verbose
  46. mkdir "${BACKUPPATH}"
  47. EOF
  48. while read PARTITION ; do
  49. FILENAME="backup-full-${PARTITION}-${FILEDATE}-${LEVEL}"
  50. echo "Backup from /dev/${PARTITION} to ${FILENAME}"
  51. dump -${LEVEL} -a -u -f - /dev/${PARTITION} \
  52. | ${NCFTPPUT} -f/root/.ncftplogin \
  53. -c ${FTP_SERVER} \
  54. "${BACKUPPATH}/${FILENAME}"
  55. done < ${HOME}/.dumppartitions