qubes.Backup 592 B

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