I searched for a while and I couldn't find solution to what I want to do in Ubuntu. I have multiple directories that I want to transfer its content to external storage server and then delete them from first machine. Simply explanation:

S1 = Main Server
ESS = External Storage Server
S1 has approx 5 directories (there may be more in the future) that I want to transfer its content to ESS and then delete them from S1.

Contents of these directories are .zip files that will be copied on almost daily basis.

  • I would recommend rsync linux.die.net/man/1/rsync where you can set params as required. – 24601 Sep 11 '19 at 7:18
  • @Graham Do you think this will be valid? rsync -rt --remove-source-files root@server:{/home/example1,/etc/example2,/srv/example3} example@x.x.x.x:/storage – Galian Sep 11 '19 at 8:03
  • I don't see why not. It appears to follow the convention mentioned here: cyberciti.biz/faq/… I'd add the --dry-run option to be certain. Shall I post that as an answer for others with the same query? – 24601 Sep 11 '19 at 8:18
  • Yeah, works great like that: rsync --remove-source-files -rte 'ssh -p23' {directory1,directory2,directory3} /mnt/share/Backups/ (i've mounted my external storage server so i could use cron to shedule it – Galian Sep 11 '19 at 14:53
  • added as an answer. Perhaps you would be kind enough to mark it up as the accepted answer so that it is easier for someone with the same question to find in the future. – 24601 Sep 11 '19 at 15:48

Précis of comments under the OP.

I would recommend the use of rsync where you can set parameters as required to delete source files files after a successful transfer to another volume.

Referring to rsync Linux Man page here the command line rsync --remove-source-files -rte 'ssh -p23' {directory1,directory2,directory3} /mnt/share/Backups/ works having referenced this link which outlines the specific arrangements for deleting source files after transfer.

This can be automated of course by using a cron job to schedule it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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