javaruntimeexecrdiff-backup

rdiff-backup java runtime exec remote multi args issues


I must execute rdiff-backup commands in Java. I desesperatly try to execute a backup command from local to remote with Runtime.

I need to use a remote schema because I can't connect to standart port 22.

As same commands work in windows shell, remote commands refuse to work, I've tried something like this :

Runtime r = Runtime.getRuntime();
Process proc = r.exec("C:/rdiff/rdiff-backup.exe "
+"--remote-schema="
+"ssh -C -p16000 %s rdiff-backup --server "
+"C:/Users/Utilisateur/Desktop/backup "
+"user@xxx.net::/var/backup");

getting this error : Fatal Error: Bad commandline options: option -C not recognized

or

String[] commandLine= {"C:/rdiff/rdiff-backup.exe",
"C:/Users/Utilisateur/Desktop/backup",
"\"-p 16000 user@xxx.net\"",
"::/var/backups"};

Runtime r = Runtime.getRuntime();
Process proc = r.exec(commandLine);

getting this error : Fatal Error: Switches missing or wrong number of arguments

Thanks for your help...


Solution

  • The first method you use is ok in java. But your command line is wrong - ssh -C is not a proper command. Make sure the command works in your shell, then use it in your first method.