Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 06-22-2015, 02:35 AM   #1
Registered: May 2013
Posts: 189

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.
rsync -avz --backup --backup-dir=/root/Documents --suffix=`date +"F"` /var/log/audit /root/Documents
Old 06-22-2015, 04:07 AM   #2
LQ Guru
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,339

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

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

Now I want they should be copied as

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

Rep: Reputation: 151Reputation: 151
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.

$ 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.


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 10:30 AM
rsync - How to skip files that are allready copied? miros84 Linux - Software 8 01-16-2013 03:47 AM
checking for suffix of object files... configure: error: cannot compute suffix of obj megras Linux - Kernel 1 10-15-2012 07:21 AM
cannot compute suffix of object files rocket42 Linux - Embedded & Single-board computer 3 04-06-2012 02: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 06:20 PM

All times are GMT -5. The time now is 10:57 AM.

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