Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to get log file for rsync operation? Does rsync also delete remote files?

796 views
Skip to first unread message

Goran Ivanic

unread,
May 4, 2008, 3:33:43 AM5/4/08
to
I am planning to use rsync for a daily backup to a remote backup server.

When I read the rsync manual it does not become clear on how to write a log file for the rsync operation.

I am missing options like:

rsync ..... -logfile=\home\backup\rsync.log -logmode=append ......

Did I miss these options?

I want to write (append !!) to the log file:

- Which files were transferred
- When the rsync operation took place
- How much bytes were transferred (total sum) in the rsync operation

How can I get such a log file otherwise?

BTW: Does rsync delete remote files (from previous rsync operations) if they are not existing
any more on the source system ?

Goran

Martin Klar

unread,
May 4, 2008, 3:48:23 AM5/4/08
to
Goran Ivanic schrieb:

> I am planning to use rsync for a daily backup to a remote backup server.
>
> When I read the rsync manual it does not become clear on how to write a log file for the rsync operation.
>
> I am missing options like:
>
> rsync ..... -logfile=\home\backup\rsync.log -logmode=append ......

maybe you are looking for

--log-file=FILE log what we're doing to the specified FILE

See man rsync.

Martin

Michael Heiming

unread,
May 4, 2008, 7:21:28 AM5/4/08
to
In comp.os.linux.misc Goran Ivanic <go...@lycos.com> wrote:
> I am planning to use rsync for a daily backup to a remote backup server.

> When I read the rsync manual it does not become clear on how to write a log file for the rsync operation.

> I am missing options like:

> rsync ..... -logfile=\home\backup\rsync.log -logmode=append ......

> Did I miss these options?

Looks like you didn't RTFM?

--log-file=FILE
--log-file-format=FORMAT

> I want to write (append !!) to the log file:

> - Which files were transferred

Is send by rsync to stdout.

> - When the rsync operation took place

Simply add a time stamp to your logfile, or see what above
"--log-file" can do for you, i have never used it.

> - How much bytes were transferred (total sum) in the rsync operation

Is send by rsync to stdout.

> How can I get such a log file otherwise?

Redirect stdout + stderr to your logfile and add a time stamp
prior to firing up rsync or see what "--log-file" can do for you.

> BTW: Does rsync delete remote files (from previous rsync operations) if they are not existing
> any more on the source system ?

Yep, using "--delete" as pointed out in the man page. Something
like the following should do the trick (untested):

rsync -avz --delete /source /destination 2>&1 >> $logfile

I left adding the time stamp as experiment for you.

Good luck

--
Michael Heiming (X-PGP-Sig > GPG-Key ID: EDD27B94)
mail: echo zvp...@urvzvat.qr | perl -pe 'y/a-z/n-za-m/'
#bofh excuse 353: Second-system effect.

Dan Stromberg

unread,
May 4, 2008, 8:55:49 PM5/4/08
to

rsync -avpl --progress --stats should be pretty close to what you want.

liha...@gmail.com

unread,
May 5, 2008, 12:00:50 AM5/5/08
to
On May 4, 2:33 am, go...@lycos.com (Goran Ivanic) wrote:
> I am planning to use rsync for a daily backup to a remote backup server.
>
> When I read the rsync manual it does not become clear on how to write a log file for the rsync operation.
>
> I am missing options like:
>
> rsync ..... -logfile=\home\backup\rsync.log -logmode=append ......
>
> Did I miss these options?
>
> I want to write (append !!) to the log file:
>
> - Which files were transferred
> - When the rsync operation took place
> - How much bytes were transferred (total sum) in the rsync operation
>
> How can I get such a log file otherwise?

what *nix box are you using? I have rsync under Ubuntu and RHEL5, and
they use very different ways to handle logfile:

for Ubuntu, I use:

rsync -aqC --delete -i --log-file=/var/log/mytest.log SRC DEST
2>&1 1>/dev/null

(logfile are in append mode automatically. at least for my server)

for RHEL5:

rsync -i --delete -avC SRC DEST 1>>/var/log/mytest.log 2>/dev/null

> BTW: Does rsync delete remote files (from previous rsync operations) if they are not existing
> any more on the source system ?

use --delete option, old files which are not on SRC will be removed
from the DESC.

lihao

Moody

unread,
May 5, 2008, 7:56:37 AM5/5/08
to
On May 4, 12:33 pm, go...@lycos.com (Goran Ivanic) wrote:
> I am planning to use rsync for a daily backup to a remote backup server.
>
> When I read the rsync manual it does not become clear on how to write a log file for the rsync operation.
>
> I am missing options like:
>
> rsync ..... -logfile=\home\backup\rsync.log -logmode=append ......
>
> Did I miss these options?
>
> I want to write (append !!) to the log file:
>
> - Which files were transferred
> - When the rsync operation took place
> - How much bytes were transferred (total sum) in the rsync operation

Possibly:

rsync -auvz -e ssh server:/path/source server:/destination/path >>
your custom-Logs file

other wise U may use sometime like below:
rsync -auvz --log-format=FORMAT -e ssh server:/path/source server:/
destination/path

where you may specify the log-format in your rsyncd.conf if you are
running a rsyncd ( daemon ) ( I never tried this, as I've been using
STDOUT option ^ Above ^ for logging the statistics of file
transfers...

Hope this helps..

Regards,

Todd H.

unread,
May 5, 2008, 8:50:44 AM5/5/08
to
go...@lycos.com (Goran Ivanic) writes:
> I am planning to use rsync for a daily backup to a remote backup server.
>
> When I read the rsync manual it does not become clear on how to write a log file for the rsync operation.
>
> I am missing options like:
>
> rsync ..... -logfile=\home\backup\rsync.log -logmode=append ......
>
> Did I miss these options?
>
> I want to write (append !!) to the log file:
>
> - Which files were transferred
> - When the rsync operation took place
> - How much bytes were transferred (total sum) in the rsync operation
>
> How can I get such a log file otherwise?

First, I'm not sure you cross posted to enough newsgroups.


You can redirect stderr and stdout to a logfile.

rsync blah blah 2>&1 >> mylogfile.txt

> BTW: Does rsync delete remote files (from previous rsync operations) if they are not existing
> any more on the source system ?

It can, if you specify the --delete option. See man rsync for more.

--
Todd H.
http://www.toddh.net/

Scott McMillan

unread,
May 5, 2008, 10:03:53 AM5/5/08
to
On 04 May 2008 07:33:43 GMT, go...@lycos.com (Goran Ivanic) wrote:

>I am planning to use rsync for a daily backup to a remote backup server.
>
>When I read the rsync manual it does not become clear on how to write a log file for the rsync operation.
>
>I am missing options like:
>
>rsync ..... -logfile=\home\backup\rsync.log -logmode=append ......
>
>Did I miss these options?
>
>I want to write (append !!) to the log file:
>
>- Which files were transferred
>- When the rsync operation took place
>- How much bytes were transferred (total sum) in the rsync operation
>
>How can I get such a log file otherwise?

With simple redirection:
rsync (your options) >>yourlogfile 2>&1

>
>BTW: Does rsync delete remote files (from previous rsync operations) if they are not existing
>any more on the source system ?

It can. See the --delete option(s) in the man page.

Scott McMillan

Guillaume Dargaud

unread,
May 5, 2008, 11:46:23 AM5/5/08
to
> How can I get such a log file otherwise?

rsync ... >> logfile
is good enough for me. Or:


--log-file=FILE log what we're doing to the specified FILE

--log-file-format=FMT log updates using the specified FMT

> BTW: Does rsync delete remote files (from previous rsync operations) if
> they are not existing
> any more on the source system ?

--delete delete extraneous files from dest dirs
--
Guillaume Dargaud
http://www.gdargaud.net/


John Murtari

unread,
May 5, 2008, 12:58:36 PM5/5/08
to
go...@lycos.com (Goran Ivanic) writes:

You really should take some time and look at a good 'man' page on
rsync. Everything you want is supported, here a few starter options:

-v, --verbose
This option increases the amount of information you are given during the transfer. By default, rsync works
silently. A single -v will give you information about what files are being transferred and a brief summary at
the end. Two -v flags will give you information on what files are being skipped and slightly more information
at the end. More than two -v flags should only be used if you are debugging rsync.

--delete
This tells rsync to delete any files on the receiving side that aren’t on the sending side. Files that are
excluded from transfer are excluded from being deleted unless you use --delete-excluded.

--log-format=FORMAT
This allows you to specify exactly what the rsync client logs to stdout on a per-file basis. The log format
is specified using the same format conventions as the log format option in rsyncd.conf.


Hope this helps!
--
John
___________________________________________________________________
John Murtari Software Workshop Inc.
jmurtari@following domain 315.635-1968(x-211) "TheBook.Com" (TM)
http://thebook.com/

0 new messages