LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-22-2015, 03:35 AM   #1
unclesamcrazy
Member
 
Registered: May 2013
Posts: 187

Rep: Reputation: 1
rsync - not able to add suffix in copied files


I want to add suffix in all copied file but not able to do with rsync.
Can you please help?
I am trying following commands.
Code:
rsync -avz --backup --backup-dir=/root/Documents --suffix=`date +"F"` /var/log/audit /root/Documents
 
Old 06-22-2015, 05:07 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
probably date +%F will work (% was missing ?) (or it was the LQ engine who removed it?)
 
Old 06-22-2015, 05:48 AM   #3
unclesamcrazy
Member
 
Registered: May 2013
Posts: 187

Original Poster
Rep: Reputation: 1
No, not working.
The files are being copied at destination still without suffix.

Suppose I want to copy directory /tmp/user
the content of /tmp/user is
log1.txt
log2.txt
log3.txt
log4.txt

Now I want they should be copied as
log1.txt.old
log1.txt.old
log1.txt.old
log1.txt.old

but not using for loop and cp command.
Can't it be done by rsync?
Please help
 
Old 06-22-2015, 03:18 PM   #4
Beryllos
Member
 
Registered: Apr 2013
Location: Massachusetts
Distribution: Debian
Posts: 304

Rep: Reputation: 121Reputation: 121
Make sure you understand how the rsync --backup option works. It makes a backup copy only if the file has changed, and then it performs the specified backup action (--backup-dir=DIR or --suffix) on the older files.

Example:
Code:
$ ls temp
a  b  c
$ rsync -a --backup --suffix=".old" temp/ temp2/    # first time rsync
$ ls temp2
a  b  c
$ rsync -a --backup --suffix=".old" temp/ temp2/    # second time rsync
$ ls temp2                                          # nothing changed
a  b  c
$ touch temp/a                                      # change 2 files
$ touch temp/b                                      # ...
$ rsync -a --backup --suffix=".old" temp/ temp2/    # third time rsync
$ ls temp2                                          # see suffix appended
a  a.old  b  b.old  c
$
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
rsync syntax - how to add suffix to files to prevent overwriting? Bloodrule Debian 4 10-06-2014 11:30 AM
rsync - How to skip files that are allready copied? miros84 Linux - Software 8 01-16-2013 04:47 AM
checking for suffix of object files... configure: error: cannot compute suffix of obj megras Linux - Kernel 1 10-15-2012 08:21 AM
cannot compute suffix of object files rocket42 Linux - Embedded & Single-board computer 3 04-06-2012 03:20 PM
What parameter do I add to RSYNC to update modified or new files to the destination? tankman1989 Linux - Software 2 02-20-2010 07:20 PM


All times are GMT -5. The time now is 04:26 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration