LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-10-2016, 02:06 PM   #1
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Rep: Reputation: 49
Equivalent to --remove-source-files for rsync in older versions of rsync


I have an OLD server where the version of rsync it's running does not have --remove-source-files available to it. How else could I do a "move" of files between two servers so the files are deleted from the source only if they transfer to the destination correctly.
 
Old 08-10-2016, 02:40 PM   #2
24x7servermanagement
Member
 
Registered: Jul 2016
Location: India
Distribution: CentOS, Redhat, Ubuntu and Debian
Posts: 57

Rep: Reputation: Disabled
Try with SCP : Serverfault

Look at scp answer(9)
 
1 members found this post helpful.
Old 08-10-2016, 02:46 PM   #3
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
Thanks. but how could I do that recursively to do an entire directory structure, preserving that structure?
 
Old 08-10-2016, 08:09 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Take the 2nd part of that soln and use the 'find' cmd to feed the list; it should also supply the paths for you. You may have to fiddle the paths a bit, especially if they are not identical at each end.
 
1 members found this post helpful.
Old 08-10-2016, 08:10 PM   #5
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
Thanks Chris, I'll see if I can get that going.
 
Old 08-11-2016, 07:12 AM   #6
24x7servermanagement
Member
 
Registered: Jul 2016
Location: India
Distribution: CentOS, Redhat, Ubuntu and Debian
Posts: 57

Rep: Reputation: Disabled
Code:
for file in /lx/test/*; do scp -rp "$file" root@192.168.1.15:/lx/scp && rm -rf "$file" ; done
Works good form me. It keeps entire directory structure as it is. Try this.
 
1 members found this post helpful.
Old 08-11-2016, 07:46 AM   #7
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
Thanks. So would it still do the rm even if the scp fails.
 
Old 08-11-2016, 10:30 AM   #8
24x7servermanagement
Member
 
Registered: Jul 2016
Location: India
Distribution: CentOS, Redhat, Ubuntu and Debian
Posts: 57

Rep: Reputation: Disabled
X; Y * *Run X and then Y, regardless of success of X

X && Y *Run Y if X succeeded

X || Y *Run Y if X failed
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
remove rsync partially transfered files tsester Linux - Newbie 2 05-16-2015 11:25 PM
[SOLVED] How to tell rsync to skip older files? Clarkman Linux - Software 3 04-19-2012 01:47 PM
rsync can not rsync files with include filter... xiutuo Linux - Server 2 07-23-2010 02:10 AM
How can I use rsync to remove source directories? tdnnash25 Linux - Server 2 10-10-2009 11:24 AM
Could I run rsync to download files from a server without rsync daemon? Richard.Yang Linux - Software 1 09-18-2009 04:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration