• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 401
  • Last Modified:

rsync shell script which saves log

Hi Experts,

I need to rsync a "docs" directory from machine1 to machine2. How do I put a log file into the destination, in a folder called rsync-logs with the date and time included? (somewhat like rdiff-backup?)

So that I can have a listing similar to this:

    increments.2006-05-03T01:30:01-07:00.dir   Wed May  3 01:30:01 2006
    increments.2006-05-04T01:30:01-07:00.dir   Thu May  4 01:30:01 2006
    increments.2006-05-05T01:30:01-07:00.dir   Fri May  5 01:30:01 2006
    increments.2006-05-08T01:30:01-07:00.dir   Mon May  8 01:30:01 2006
    increments.2006-05-09T01:30:01-07:00.dir   Tue May  9 01:30:01 2006
    increments.2006-05-10T01:30:01-07:00.dir   Wed May 10 01:30:01 2006
    increments.2006-05-11T01:30:01-07:00.dir   Thu May 11 01:30:01 2006
    increments.2006-05-12T01:30:01-07:00.dir   Fri May 12 01:30:01 2006
    increments.2006-05-13T01:30:02-07:00.dir   Sat May 13 01:30:02 2006

Thanks in advance!

Sean
0
sow56091
Asked:
sow56091
1 Solution
 
leisnerCommented:
I asssume you want to:
     rsync from machine1 to machine2
    put a log of the transfer on machine2?

You can easily do it in a script which first runs rsync, redirecting the log
to a file, then rsync-ing the log file to whatever you want to call it...

I think!!
0
 
sow56091Author Commented:
Yes, I agree, but how do I store the current date/time in a variable and refer to the that in bash script for my cron job?

Sean
0
 
yuzhCommented:
>>but how do I store the current date/time in a variable and refer to the that in bash script for my cron job?

you can do:

CTIME=`date`

# format the date time in var:
CTIME=`date +%Y%m%d%H%M`

eg:

CTIME=`date +%Y%m%d%H%M`

#create a log with time stamp
myscript > /path/to/log.$CTIME  2>&1

......

use cron to run your script.
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now