0

I'm trying to MOVE files from remote server to local folder. Files need to be REMOVED from remote source. I tried:

rsync -avz --remove-source-files ssh remote_user@remote_machine:/home/remote_user/a_folder/ ~/a_folder/

which copies but does not remove the files from the remote source

Thanks

4
  • Files should have been deleted, or an error at least printed. rsync would leave directories around. Could that be the source of confusion?
    – chutz
    Nov 1, 2012 at 14:55
  • What error messages does the command provide ?
    – user9517
    Nov 2, 2012 at 8:18
  • I'm aware of rsync leaving empty folders behind. Files are left in the source too. No errors show on rsync output. I'm wondering if it could be some kind of deleting permission problem. I remember unsuccessfully trying to delete the whole folder in ftp.
    – Shreko
    Nov 2, 2012 at 13:47
  • It must have been something related to vsproftpd settings that did not allow files deletion. After I rebuilt VPS slice with ProFTPd original command works as expected, files are removed from remote location, with folder tree left. Thank you all for your help.
    – Shreko
    Nov 3, 2012 at 12:35

1 Answer 1

0

Does it have to happen in one command, you could just copy, then delete?

Another option would be to mount via SSHFS and use mv to move the files.

UPDATE

Two commands isn't really much more difficult or complex than one;

rsync -avz ssh remote_user@remote_machine:/home/remote_user/a_folder/ ~/a_folder/
ssh remote_user@remote_machin rm -rf /home/remote_user/a_folder/*
5
  • It does not have to happen in one command, but I would prefer a simple to configure solution
    – Shreko
    Nov 1, 2012 at 14:50
  • I have updated the answer, you can run rm via SSH
    – Baldrick
    Nov 1, 2012 at 14:54
  • 1
    rsync would delete only files that are successfully copied. With rm after rsync, you would delete any files that pop up after (or during) the rsync.
    – chutz
    Nov 1, 2012 at 14:57
  • You're saying that rsync would delete files that are succesfully copied. The command in my original post are successfully copied but are not removed. Also, rm can be a problem as the source is a directory in which a webcam stores images every few seconds
    – Shreko
    Nov 1, 2012 at 15:05
  • 1
    You can use rsync to delete files after successful transfer with the "--remove-source-files" option, anything left over will get transferred next time, removing the need and danger of rm. This is a documented and working option; If this isn't working for you I would start by turning up the verbosity on rsync and checking file permissions on the user running the rsync command, post your results back here.
    – Baldrick
    Nov 1, 2012 at 16:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .