# Using rsync to backup over network

## jordanwb

I want to use rsync to backup the contents of my laptop's file system to a folder on another machine. I used grync to make this command:

```
sudo rsync -r -t -p -o -g -v --progress / backups@192.168.1.3::share/JORDAN-LAPTOP
```

but it fails and displays messages like these:

```
sbin/

rsync: recv_generator: mkdir "/JORDAN-LAPTOP/sbin" (in share) failed: Permission denied (13)

*** Skipping any contents from this failed directory ***
```

Is it because the backups account can't create folders with root ownership?

----------

## BradN

rsync needs to be running as root on the machine receiving the backup to even allow it to create files owned by other users.  If this is a problem, it might be best to consider tar for backups, but this loses a lot of the fancy features rsync provides.

Alternately, you can have rsync just make all the files as its own user/group in the backup, but you would want another way to back up the ownership info, which I'm not sure of a good method for (tar does not seem to do this without file data).  In practice you could probably get by with losing the ownership info as long as you have an ls -alR dump or something of that sort to refer back to in resetting the ownership.

----------

## Hu

If the remote system can handle extended attributes, you could use the rsync option --fake-super to preserve ownership without having privilege.  See man rsync for details.

If you want incremental updates and are willing to have a changed file sent in full, tar with --newer might be an option.

----------

## BradN

I'll have to remember that trick... though I haven't yet played with extended attributes even so I guess I've got a little catching up to do...

----------

## jordanwb

The remote computer is running Ubuntu Server so it probably has extended attributes in the kernel but I don't know if I need to set up anything special to use it.

After doing some googling I came up with this:

```
rsync -avp --numeric-ids --exclude /dev,/dev/shm,/proc --delete / backups@192.168.1.3:JORDAN-LAPTOP
```

----------

