You are not logged in.

#1 2008-09-01 19:26:53

dsr
Member
Registered: 2008-05-31
Posts: 187

[SOLVED] rsync with USB flash drive

Hey, I'm trying to settle on an ideal backup solution to archive my small /home partition to my 8GB (8 x 1000^3 bytes, not 8 x 1024^3 bytes) USB flash drive. Currently, I've been running

# tar --numeric-owner -cvpzf backup-`date '+%G-%m-%d'`.tar.gz /home

from a directory on my flash drive. I'd prefer to use rsync since it only updates files that have changed, but my flash drive gives me permission errors because FAT32 apparently doesn't support UNIX permissions. I don't want to change the filesystem type because I need the interoperability with Windows (I use the drive for file transfers in addition to backups). How can I get rsync working properly?

Last edited by dsr (2008-09-03 22:36:41)

Offline

#2 2008-09-01 20:32:22

byte
Member
From: Düsseldorf (DE)
Registered: 2006-05-01
Posts: 1,872

Re: [SOLVED] rsync with USB flash drive

You could create an ext2 image file on the flash drive and mount that with -o loop.


I hate sigs. This one only exists to remind myself to get an avatar.

Offline

#3 2008-09-01 20:39:47

ninian
Member
From: Scotland
Registered: 2008-02-24
Posts: 642
Website

Re: [SOLVED] rsync with USB flash drive

Usually with rsync, your command for backing up would be:

rsync -av /source/ /target/

(maybe with the --delete switch too)

From 'man rsync', here's what the -a switch implies:

-a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)

so with FAT32, you would have to check which of the -rlptgoD switches you wouldn't want.
I did this a while back and I'm sure it worked okay once you get rid of the non-applicable switches.

Offline

#4 2008-09-01 21:28:44

byte
Member
From: Düsseldorf (DE)
Registered: 2006-05-01
Posts: 1,872

Re: [SOLVED] rsync with USB flash drive

Even if you omit the permissions/owner stuff (which you shouldn't), FAT still sucks because it doesn't feature an accurate timestamp. File size and date are the two main points for rsync in order to transfer only changed files.


I hate sigs. This one only exists to remind myself to get an avatar.

Offline

#5 2008-09-01 22:15:35

dsr
Member
Registered: 2008-05-31
Posts: 187

Re: [SOLVED] rsync with USB flash drive

byte: Thanks, that's probably my best bet, even though I wouldn't be able to access my /home files from within Windows. In order to transfer files to a Windows system, I would have to make separate copies of the files to transfer. That's okay, though. How do I create the image file and format it with ext2?

ninian: I tried that (rsync --rptD --delete /home /path/to/my/flash/drive) before, but the only difference between that and

rsync -a --delete /home /path/to/my/flash/drive

was that rsync didn't spit out warnings. Ideally, I would want to be able to preserve user and group ownership. Although, being able to access the rsync tree from within Windows is tempting. Hmm.

Offline

#6 2008-09-01 23:14:20

byte
Member
From: Düsseldorf (DE)
Registered: 2006-05-01
Posts: 1,872

Re: [SOLVED] rsync with USB flash drive

Do you know http://www.fs-driver.org/ ? If you don't intend to use the stick on Windows systems where you don't have admin rights but only on your private ones, it seems like a good idea.


I hate sigs. This one only exists to remind myself to get an avatar.

Offline

#7 2008-09-01 23:52:25

dsr
Member
Registered: 2008-05-31
Posts: 187

Re: [SOLVED] rsync with USB flash drive

Oh, I don't use Windows on my own machines. I have never and hopefully will never. The Windows machines are at school, where I don't have admin privileges. Anyway, how do I create the ext2 image file on the drive?

Offline

#8 2008-09-02 00:13:43

byte
Member
From: Düsseldorf (DE)
Registered: 2006-05-01
Posts: 1,872

Re: [SOLVED] rsync with USB flash drive

dd if=/dev/zero of=ext2.img bs=1M count=50
modprobe loop
losetup /dev/loop0 ext2.img
mke2fs -v -m0 /dev/loop0
mount -t ext2 /dev/loop0 /mnt/tmp
...do stuff in /mnt/tmp...
umount /mnt/tmp
losetup -d /dev/loop0

Creates a 50 MB file full of zeroes and sets up a loop mount, which then in turn gets formatted as ext2.


I hate sigs. This one only exists to remind myself to get an avatar.

Offline

#9 2008-09-02 00:50:31

dsr
Member
Registered: 2008-05-31
Posts: 187

Re: [SOLVED] rsync with USB flash drive

Thanks a lot! Two questions:

1. Are those MB (1000^2) or MiB (1024^2)?
2. Does count specify the initial size or the maximum size of the image?

Offline

#10 2008-09-02 01:06:24

byte
Member
From: Düsseldorf (DE)
Registered: 2006-05-01
Posts: 1,872

Re: [SOLVED] rsync with USB flash drive

MiB. With dd you specify a fixed block size (512 byte aka 1 disk sector by default) and the number of iterations. Using bs=50M and count=1 would have been the same. Also: man dd, man losetup ;)
I'm not sure if or how you could enlarge the image file once everything is set up and the filesystem is created. I know that Ext2/3 supports resizing, but no idea how to handle that with loop mounts.

Last edited by byte (2008-09-02 01:07:35)


I hate sigs. This one only exists to remind myself to get an avatar.

Offline

#11 2008-09-02 02:48:56

dsr
Member
Registered: 2008-05-31
Posts: 187

Re: [SOLVED] rsync with USB flash drive

Thank you so much! It worked. I'll update the rsync tree by running the following script with my flash drive mounted at /media/cruzer:

#!/bin/sh
# backup.sh
# NOTE: must be run as root

losetup /dev/loop0 /media/cruzer/backup.img && \
mkdir -p /mnt/tmp/"$$" && \
mount -t ext2 /dev/loop0 /mnt/tmp/"$$" && \
rsync -a --delete /home /mnt/tmp/"$$" && \
umount /mnt/tmp/"$$" && \
rm -r /mnt/tmp/"$$" && \
losetup -d /dev/loop0

Offline

Board footer

Powered by FluxBB