qubes.Backup 624 B

1234567891011121314151617181920212223
  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-%d-%m-%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. TYPE=`type -t $COMMAND`
  13. if [ "$TYPE" == "file" ] ; 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