Guest User

Untitled

a guest
Jul 18th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <?php
  2. define('BACKUP_RSYNC' , 1);
  3. define('BACKUP_RSYNCAUTH', 2);
  4. define('BACKUP_SCP', 3);
  5.  
  6. /**
  7. * Perform a backup for the VE.
  8. * There are different possibilities to perform a backup. The first
  9. * argument must specify the method to be used. The remaining
  10. * arguments then depend on the chosen method:
  11. *
  12. * - BACKUP_RSYNC - Use rsync: $host
  13. * - BACKUP_RSYNCAUTH - Use rsync with auth: $host, $user, $password
  14. * - BACKUP_SCP - Use scp, parameters: $host
  15. */
  16. function makeBackup ()
  17. {
  18. $args = func_get_args();
  19. $cmd = '';
  20. switch ($args[0])
  21. {
  22. case BACKUP_RSYNC:
  23. $cmd = 'rsync' . $args[1];
  24. break;
  25.  
  26. case BACKUP_RSYNCAUTH:
  27. $cmd = 'rsync --user '.$args[2].' --password '.$args[3].' '.$args[4];
  28. break;
  29.  
  30. // usw...
  31. }
  32. exec($cmd);
  33. }
Add Comment
Please, Sign In to add comment