Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Rsync

...

is

...

a

...

data

...

transfer

...

tool.

...

To

...

use

...

rsync

...

you

...

will

...

be

...

provide

...

it

...

with

...

a

...

source,

...

and

...

a

...

destination.

...

For

...

each

...

file

...

in

...

the

...

source,

...

rsync

...

will

...

first

...

look

...

to

...

see

...

if

...

the

...

file

...

exists

...

in

...

the

...

target.

...

If

...

not,

...

then

...

rsync

...

will

...

transfer

...

a

...

copy

...

of

...

the

...

file

...

to

...

the

...

target.

...

If

...

file

...

does

...

exist

...

on

...

the

...

target,

...

then

...

rsync

...

confirms

...

that

...

the

...

files

...

are

...

the

...

same.

...

If

...

not,

...

then

...

it

...

determines

...

the

...

smallest

...

amount

...

of

...

data

...

that

...

needs

...

to

...

be

...

transferred

...

to

...

make

...

the

...

target

...

file

...

look

...

like

...

the

...

source

...

file.

...

This

...

makes

...

rsync

...

ideal

...

for

...

mirroring

...

sets

...

of

...

files.

...

Because

...

rsync

...

ignores

...

files

...

that

...

are

...

up

...

to

...

date

...

it's

...

also

...

useful

...

for

...

resuming

...

a

...

transfer

...

that

...

might

...

have

...

gotten

...

interrupted.

...

However,

...

this

...

powerful

...

piece

...

of

...

software

...

can

...

easily

...

be

...

used

...

to

...

create

...

a

...

mess,

...

or

...

damage

...

files.

...

If

...

you

...

wish

...

to

...

use

...

rsync

...

you

...

should

...

carefully

...

read

...

through

...

this

...

document

...

to

...

make

...

sure

...

you

...

understand

...

its

...

proper

...

use.

...

It

...

does

...

also

...

require

...

a

...

bit

...

more

...

familiarity

...

with

...

how

...

files

...

are

...

stored,

...

and

...

accessed

...

in

...

UNIX.

...

If

...

you

...

are

...

still

...

not

...

comfortable

...

with

...

this,

...

you

...

should

...

visit

...

our

...

New

...

Users

...

Guide

...

which

...

has

...

some

...

references

...

for

...

learning

...

to

...

work

...

with

...

UNIX.

...

You

...

might

...

also

...

refer

...

to

...

our

...

UNIXary

...

which

...

defines

...

some

...

commonly

...

used

...

terms.

...

UNIX

...

users

...

(and

...

Mac

...

by

...

use

...

of

...

Terminal.app)

...

can

...

use

...

rsync

...

by

...

typing

...

}
Code Block
rsync opts  src tgt
{code}

src

...

and

...

tgt

...

are

...

the

...

locations

...

that

...

you

...

want

...

to

...

keep

...

synced.

...

The

...

rule

...

is

...

that

...

tgt

...

will

...

be

...

made

...

to

...

look

...

like

...

src.

...

There

...

are

...

several

...

options.

...

First,

...

you

...

can

...

just

...

use

...

short

...

names.

...

For

...

example,

...

rsync

...

a

...

b

...

will

...

sync

...

object

...

a

...

to

...

object

...

b

...

where

...

both

...

a

...

and

...

b

...

are

...

in

...

your

...

current

...

working

...

directory.

...

By

...

object,

...

it

...

is

...

meant

...

either

...

a

...

file

...

or

...

a

...

directory.

...

For

...

example,

...

rsync

...

a

...

b

...

will

...

sync

...

a

...

to

...

b.

...

If

...

a,

...

and

...

b

...

are

...

both

...

files,

...

then

...

b

...

is

...

updated

...

to

...

look

...

like

...

a.

...

If

...

b

...

is

...

a

...

directory,

...

then

...

b/a

...

is

...

updated

...

to

...

look

...

like

...

a.

...

Keep

...

in

...

mind

...

that

...

"update"

...

means

...

"created"

...

if

...

it

...

doesn't

...

exist.

...

If

...

a

...

is

...

a

...

directory,

...

then

...

rsync

...

will

...

fail

...

because,

...

by

...

default,

...

rsync

...

will

...

not

...

transfer

...

directories.

...

You

...

can

...

get

...

around

...

this

...

by

...

using

...

the

...

-a

...

option.

...

In

...

other

...

words,

...

rsync

...

-a

...

a

...

b

...

will

...

transfer

...

the

...

directory

...

a

...

to

...

become

...

b.

...

Typically,

...

you

...

will

...

almost

...

always

...

be

...

using

...

-a,

...

since

...

it

...

sets

...

a

...

number

...

of

...

other

...

options

...

which

...

are

...

used

...

to

...

help

...

rsync

...

mirror

...

sets

...

of

...

files

...

between

...

two

...

locations.

...

With

...

this

...

use

...

of

...

rsync

...

b/a

...

is

...

created

...

or

...

updated.

...

If

...

you

...

use

...

a/

...

as

...

a

...

source,

...

then

...

the

...

contents

...

of

...

a

...

are

...

placed

...

in

...

b.

...

You

...

can

...

also

...

use

...

the

...

trailing

...

slash

...

with

...

a

...

target.

...

For

...

example,

...

if

...

a

...

is

...

a

...

file,

...

and

...

you

...

run

...

rsync

...

-a

...

a

...

b

...

then

...

either

...

b

...

(if

...

it

...

is

...

a

...

file),

...

or

...

b/a

...

(if

...

it

...

is

...

a

...

directory)

...

is

...

updated.

...

In

...

the

...

case

...

that

...

you

...

want

...

to

...

guard

...

against

...

typos

...

overwriting

...

a

...

file,

...

you

...

can

...

use

...

b/.

...

Then

...

if

...

what

...

you

...

type

...

is

...

not

...

a

...

directory,

...

rsync

...

will

...

refuse

...

to

...

transfer

...

the

...

file.

...

To

...

sum

...

up

...

object

...

meaning

...


a

...

b

...

sync

...

object

...

(file

...

or

...

directory)

...

a

...

to

...

(file

...

or

...

directory

...

b)

...


a/

...

b

...

sync

...

contents

...

of

...

directory

...

a

...

to

...

b

...


a b/

...

sync

...

a

...

to

...

directory

...

b

...


a/

...

b/

...

sync

...

directory

...

a/

...

to

...

b/

...

Syncing

...

to

...

a

...

Remote/Host

...

Until

...

now

...

we've

...

just

...

assumed

...

that

...

we

...

are

...

syncing

...

files

...

in

...

the

...

same

...

directory.

...

However,

...

rsync

...

will

...

also

...

sync

...

files

...

between

...

directories.

...

For

...

example,

...

if

...

you

...

have

...

modified

...

files

...

in

...

your

...

home

...

directory,

...

you

...

might

...

want

...

to

...

make

...

sure

...

the

...

changed

...

files

...

are

...

in

...

your

...

personal

...

directory

...

in

...

your

...

lab

...

folder.

...

In

...

this

...

case

...

you

...

could

...

run,

...

rsync

...

-a

...

a

...

/share/FooLab/bar1234/ProjectFiles

...

which

...

creates

...

or

...

updates

...

/share/FooLab/bar1234/ProjectFiles/a.

...

You

...

can

...

reverse

...

this

...

off

...

course.

...

Finally,

...

rsync

...

allows

...

either

...

the

...

source

...

or

...

the

...

target

...

on

...

a

...

remote

...

host.

...

This

...

allows

...

you

...

to

...

sync

...

files

...

to

...

a

...

remote

...

host,

...

using

...

the

...

syntax

...

rsync

...

-a

...

a

...

remote_host:dir

...

which

...

places

...

the

...

object

...

a

...

in

...

the

...

directory

...

dir

...

on

...

the

...

the

...

host

...

remote_host.

...

If

...

dir

...

is

...

a

...

full

...

path,

...

then

...

that

...

is

...

where

...

the

...

syncing

...

is

...

done.

...

If

...

it

...

not,

...

then

...

the

...

syncing

...

is

...

done

...

in

...

~/dir

...

where

...

~

...

is

...

the

...

directory

...

your

...

are

...

logged

...

in

...

to

...

when

...

you

...

access

...

the

...

remote

...

system

...

using

...

ssh.

...

If

...

you

...

don't

...

provide

...

a

...

directory

...

at

...

all,

...

then

...

~/a

...

is

...

synced.

...

Other Options

Besides -a

...

to

...

set

...

up

...

mirroring,

...

rsync

...

comes

...

with

...

a

...

number

...

of

...

other

...

options.

...

For

...

example,

...

you

...

can

...

use

...

--verbose

...

to

...

see

...

the

...

list

...

of

...

files

...

that

...

are

...

being

...

transferred.

...

Over

...

time

...

you

...

may

...

find

...

that

...

there

...

are

...

files

...

that

...

are

...

being

...

transferred

...

that

...

you

...

don't

...

care

...

about.

...

For

...

example,

...

you

...

might

...

be

...

using

...

rsync

...

to

...

copy

...

the

...

contents

...

of

...

your

...

home

...

directory

...

over.

...

In

...

this

...

case,

...

you

...

may

...

notice

...

files

...

being

...

synced

...

over

...

that

...

you

...

don't

...

care

...

about.

...

For

...

example,

...

I

...

notice

...

that

...

when

...

I

...

rsync

...

my

...

home

...

directory,

...

cache

...

files

...

created

...

by

...

pages

...

created

...

by

...

firefox.

...

In

...

this

...

case

...

using

...

--exclude=.mozilla/firefox/eog3nqtx.default/Cache

...

ensures

...

that

...

these

...

files

...

files

...

don't

...

care

...

copied

...

over.

...

You

...

can

...

use

...

--exclude

...

multiple

...

times,

...

and

...

if

...

you

...

have

...

enough

...

of

...

them,

...

you

...

can

...

put

...

them

...

into

...

a

...

file;

...

then,

...

you

...

can

...

use

...

--exclude-from=FILE

...

to

...

tell

...

rysnc

...

to

...

use

...

the

...

named

...

file

...

as

...

a

...

list

...

of

...

patterns

...

to

...

exclude.

...

You

...

may

...

also

...

want

...

to

...

use

...

--delete

...

which

...

tells

...

rsync

...

to

...

remove

...

deleted

...

files

...

in

...

the

...

target

...

since

...

by

...

default

...

it

...

doesn't

...

do

...

this.

...

Another

...

way

...

to

...

avoid

...

rsyncing

...

lots

...

of

...

junk

...

is

...

to

...

only

...

rsync

...

the

...

things

...

you

...

are

...

interested

...

in.

...

You

...

can

...

either

...

list

...

of

...

objects

...

can

...

be

...

used

...

in

...

--include-from=FILE,

...

or

...

--files-from=FILE

...

where

...

FILE

...

is

...

again

...

the

...

file

...

name.

...

The

...

difference

...

is

...

that

...

the

...

include

...

file

...

used

...

in

...

include-from

...

can

...

have

...

wildcards

...

(as

...

can

...

exclude-from).

...

For

...

more

...

information

...

about

...

wildcards,

...

run

...

man

...

rsync

...

and

...

read

...

about

...

it.

...

Also,

...

--dry-run,

...

--list-only,

...

and

...

--itemize-changes

...

are

...

good

...

ways

...

to

...

see

...

what

...

rsync

...

is

...

doing,

...

or

...

to

...

test

...

what

...

it

...

might

...

do.

...

Finally,

...

sometimes

...

on

...

remote

...

systems

Rsync as a Backup Tool

This section will provide a mechanism for CCBB users to easily back their Mac or Linux laptops up. First, prep by logging into files.ccbb.utexas.edu

...

using

...

ssh,

...

and

...

then

...

changing

...

to

...

your

...

lab's

...

bulk

...

share.

...

Please

...

do

...

not

...

use

...

home

...

directories

...

for

...

this,

...

as

...

we

...

do

...

not

...

have

...

space

...

to

...

do

...

this.

...

Anybody

...

that

...

we

...

have

...

obligations

...

to

...

backup

...

will

...

also

...

be

...

a

...

member

...

of

...

a

...

lab

...

with

...

a

...

lab

...

share.

...

Within

...

your

...

lab

...

share

...

you

...

should

...

have

...

a

...

personal

...

folder

...

which

...

only

...

you,

...

and

...

your

...

lab

...

head

...

can

...

access.

...

Make

...

a

...

unique

...

for

...

your

...

backup

...

(say

...

LAPTOP).

...

Next

...

on

...

your

...

system

...

run

...

the

...

commands

...

mkdir

...

~/bin

...


mkidr

...

~/.ccbb-rsync-backup

...

Go

...

into

...

the

...

directory

...

~/bin,

...

and

...

use

...

an

...

editor

...

to

...

create

...

file

...

called

...

sync2files

...

which

...

contains

...

the

...

blocks

...

of

...

text

...

between

...

the

...

-begin

...

-

...

and

...

-

...

end-

...

lines

...

below

– begin –

– end –

Once the script is done, run the command

chmod u+x sync2files

Next go into ~/.ccbb-rsync-backup,

...

and

...

create

...

a

...

file

...

called

...

include,

...

and

...

a

...

file

...

called

...

exclude.

...

This

...

can

...

be

...

empty,

...

but

...

over

...

time

...

you

...

may

...

want

...

to

...

adjust

...

the

...

contents

...

of

...

these

...

files.

...

For

...

example,

...

you

...

may

...

notice

...

cache

...

files

...

in

...

your

...

home

...

directory,

...

or

...

other

...

files

...

that

...

you

...

don't

...

want

...

backed

...

up

...

(such

...

as

...

your

...

music

...

collection

...

which

...

is

...

non-work

...

related).

...

Those

...

can

...

be

...

put

...

in

...

the

...

exclude

...

file.

...

Or

...

if

...

you

...

wish

...

to

...

only

...

back

...

up

...

specific

...

items,

...

or

...

need

...

to

...

back

...

up

...

items

...

other

...

than

...

~,

...

you

...

can

...

add

...

entries

...

to

...

the

...

include

...

file.

...