qubes.Backup 601 B

123456789101112131415161718192021222324
  1. #!/bin/sh
  2. echo Starting Backupcopy
  3. read args
  4. echo Arguments: $args
  5. if [ -d "$args" ] ; then
  6. echo "Performing backup to directory $args"
  7. TARGET="$args/qubes-backup-`date +'%Y-%m-%dT%H%M%S'`"
  8. echo "Copying STDIN data to $TARGET"
  9. cat > $TARGET
  10. else
  11. echo "Checking if arguments is matching a command"
  12. COMMAND=`echo $args | cut -d ' ' -f 1`
  13. if type "$COMMAND"; then
  14. echo "Redirecting STDIN to $args"
  15. # Parsing args to handle quotes correctly
  16. # Dangerous method if args are uncontrolled
  17. eval "set -- $args"
  18. $@
  19. else
  20. echo "Invalid command $COMMAND"
  21. exit 1
  22. fi
  23. fi