Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
    
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 '12 at 14:55
    
What error messages does the command provide ? –  Iain Nov 2 '12 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 '12 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 '12 at 12:35

1 Answer 1

up vote 0 down vote accepted

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/*
share|improve this answer
    
It does not have to happen in one command, but I would prefer a simple to configure solution –  Shreko Nov 1 '12 at 14:50
    
I have updated the answer, you can run rm via SSH –  jwbensley Nov 1 '12 at 14:54
    
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 '12 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 '12 at 15:05
    
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. –  jwbensley Nov 1 '12 at 16:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.