Solved

ubuntu incremental backup script

Posted on 2013-11-24
6
375 Views
Last Modified: 2013-11-29
Hi Experts.

Need a shell script for incremental backup.
when we run script first time it take full backup.
next time we changes in source file.
And again run script that time it tale backup only modified file in new date folder.

Thanks & Regards,
Xeroxzerox
0
Comment
Question by:xeroxzerox
  • 2
  • 2
  • 2
6 Comments
 
LVL 1

Assisted Solution

by:alexziv
alexziv earned 150 total points
ID: 39673876
0
 
LVL 6

Author Comment

by:xeroxzerox
ID: 39673883
i've already done by webguru script but it's not working.
0
 
LVL 1

Expert Comment

by:alexziv
ID: 39673895
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 19

Expert Comment

by:xterm
ID: 39676167
Here's a simple script that uses the "itemize" function of rsync to tell you which files have changed, and put those in a seperate dated folder, which is what I think you were requesting:

#!/bin/sh

STAMP=`date +%Y%m%d-%H%M%S`

SRC="sourcefolder"
DST="destfolder"
CHG="$DST/$STAMP"
OUTPUT="rsync.out"

rsync -avi $SRC $DST > $OUTPUT

for CHANGE in `grep ^\>f $OUTPUT | awk '{print $2}'`;
do
        if [ ! -d $CHG ]; then
                mkdir $CHG
        fi
        cp -v $CHANGE $CHG
done

rm -f $OUTPUT

Open in new window

0
 
LVL 6

Author Comment

by:xeroxzerox
ID: 39676659
First time when i've ran script i found below output

|-- 20131201-192343
|   |-- 1.txt
|   |-- 2.txt
|   |-- 3.txt
|   |-- 4.txt
|   `-- 5.txt
|-- xerox
|   |-- hr
|   |   `-- user1
|   |       `-- 5.txt
|   |-- IT
|   |   |-- user2
|   |   |   `-- 3.txt
|   |   `-- user3
|   |       |-- 1.txt
|   |       `-- 2.txt
|   `-- pa
|       `-- user4
|           `-- 4.txt
`-- rsync.out
that time it make a two backup
next time i've modified in hr>user1>5.txt and run the script.Now output is
|-- 20131201-192343
|   |-- 1.txt
|   |-- 2.txt
|   |-- 3.txt
|   |-- 4.txt
|   `-- 5.txt
|-- 20131201-192554
|   `-- 5.txt
|-- xerox
|   |-- HR
|   |   `-- user1
|   |       `-- 5.txt
|   |-- it
|   |   |-- user2
|   |   |   `-- 3.txt
|   |   `-- user3
|   |       |-- 1.txt
|   |       `-- 2.txt
|   `-- pa
|       `-- user4
|           `-- 4.txt
`-- rsync.out

But now i want a output like that.
|-- 20131201-192554
|   |-- HR
|   |   `-- user1
|   |       `-- 5.txt
|-- xerox
|   |-- HR
|   |   `-- user1
|   |       `-- 5.txt
|   |-- it
|   |   |-- user2
|   |   |   `-- 3.txt
|   |   `-- user3
|   |       |-- 1.txt
|   |       `-- 2.txt
|   `-- pa
|       `-- user4
|           `-- 4.txt
`-- rsync.out
0
 
LVL 19

Accepted Solution

by:
xterm earned 350 total points
ID: 39677760
Here you go, modified to use tar instead of cp so it will create the directories in the structure you requested:

#!/bin/sh

STAMP=`date +%Y%m%d-%H%M%S`

SRC="sourcefolder"
DST="destfolder"
CHG="$DST/$STAMP"
OUTPUT="rsync.out"

rsync -avi $SRC $DST > $OUTPUT

for CHANGE in `grep ^\>f $OUTPUT | awk '{print $2}'`;
do
        if [ ! -d $CHG ]; then
                mkdir -p $CHG
        fi
        (tar cpf - $CHANGE ) | (cd $CHG && tar xvfp -)
done

rm -f $OUTPUT

Open in new window

0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

937 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now