Backup of /Home

Hi

I assume this is done at root su in the konsole?
I would like to copy the whole of the /home including the hidden files

I can use a dingle 8GB, I have the device node and the mounting point - not sure which should be used and what to put after cp?

cp ?/home /mount/media/BRIAN

should the second be the device node /dev/sdb1
or the mountpoint /media/BRIAN_B

Thanks

Su to get rootly powers first. Then if there exists an empty directory called _BRIANB in the directory /media – then enter this:

cp -a /home/. /media/_BRIANB

That will copy all the directories under the /home directory across to the directory _BRIANB. Note it will not reproduce the directory /home, just the directories under /home (like /jon and /henrietta etc)

Note to include the period in /home/. because that switches on the hidden-file reader.

If you want it to appear exactly in _BRIANB, including /home, then do these two commands:

mkdir /media/_BRIANB/home
cp -a /home/. /media/_BRIANB/home

The archive switch -a in the copy command is the same as switches -dpR. It preserves permissions, ownership and time stamps and also copies links.

I keep forgetting things! Oh well, off to watch TV I think.

signetone wrote:

>
> Hi
>
> I assume this is done at root su in the konsole?
> I would like to copy the whole of the /home including the hidden files
>
> I can use a dingle 8GB, I have the device node and the mounting point -
> not sure which should be used and what to put after cp?
>
> cp ?/home /mount/media/BRIAN
>
> should the second be the device node /dev/sdb1
> or the mountpoint /media/BRIAN_B
>
> Thanks
>
>

Mount the device you are to copy to (usually /mnt) with write permissions

cp -a /home /mnt/BRIAN

(or cp -av if you want to watch it in action)

man cp will give you the info

Alan

Sorry about the mistake in name of USB Device BRIAN_B_

mkdir /media/BRIAN_B_/home
cp -a /home/. /media/BRIAN_B_/home

The first command worked fine.

For the second I got many lines of feedback similar to

cp: failed to preserve ownership for /media/BRIAN_B_/home/./brian/bin/Script/backupscript.sh': Operation not permitted cp: failed to preserve ownership for /media/BRIAN_B_/home/./brian/bin/Script’: Operation not permitted
cp: failed to preserve ownership for /media/BRIAN_B_/home/./brian/bin/.directory': Operation not permitted cp: failed to preserve ownership for /media/BRIAN_B_/home/./brian/bin/Turboprint/TURBOPRINT.TPKEY’: Operation not permitted
cp: failed to

Any advice please

Thanks

Just tried it myself. Works for me.

So, let’s look at the permissions aspect and the filesystems.
First, did the usb drive automount or did you mount it yourself and if you mounted it yourself please give details of the method.

Second, please post the dialogue you get with these commands issued in a console window:
To check permissions on the mount:

 ls -l /media

To check permissions on the new home:

ls -l /media/_BRIANB

To check what did get copied and the form of it:

 ls -l /media/_BRIANB/home

To check the filesystem that was mounted:

 sudo /sbin/fdisk -l

Hi

I am using a different dingle [8 GB]- I now realize it is not big enough anyway as the music folder is in home.
but anyway the same thing happens with the files

Thanks

@signetone: Here is the information you sent me:

linux-p4d:/home/brian # ls -l /media
total 16
drwxr-xr-x 3 brian root 4096 1970-01-01 01:00 BRIAN_A_
-rw-r–r-- 1 root root 179 2009-03-12 14:32 .hal-mtab
-r-Sr----- 1 root root 0 2006-12-20 15:17 .hal-mtab-lock
drwx------ 2 root root 4096 2007-12-18 19:20 sdb1
linux-p4d:/home/brian #

linux-p4d:/home/brian # ls -l /media/BRIAN_A_
total 4
drwxr-xr-x 4 brian root 4096 2009-03-12 14:03 home
linux-p4d:/home/brian #

linux-p4d:/home/brian # ls -l /media/BRIAN_A_/home
total 8
drwxr-xr-x 8 brian root 4096 2009-03-12 14:09 brian
drwxr-xr-x 2 brian root 4096 2006-08-14 13:17 lost+found
linux-p4d:/home/brian #

linux-p4d:/home/brian # sudo /sbin/fdisk -l

Disk /dev/sda: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 1 262 2104483+ 82 Linux swap / Solaris
/dev/sda2 * 263 2873 20972857+ 83 Linux
/dev/sda3 2874 38913 289491300 83 Linux

Disk /dev/sdb: 8065 MB, 8065646080 bytes
8 heads, 32 sectors/track, 61535 cylinders
Units = cylinders of 256 * 512 = 131072 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 61536 7876591+ b W95 FAT32
linux-p4d:/home/brian #

I’ll respond later. Distracted.

Hi,

I’ve used this when transferring my /home partition from my 120GB HD to my 250GB HD.

EASEUS Disk Copy: Free Disk Copy, Disk Clone, Partition Copy Software. Sector by Sector for hard drive backup freeware.

It’s free. Download the .zip. Extract the .iso file and burn that to a cd. Then restart your computer and boot from cd. You choose the partition you want to copy and then the destination to copy to.

You can also do full hard drive backups, backing up everything on the hard drive as it is.

Since you’re not booting up in linux, your computer will be rendered unusable while it’s copying and transferring the data but it works.

I’ve backed up to a 500GB external usb drive, with 120GB of data it took about 18 hours.

It’s a little faster when moving partitions back onto your hard drive.

When you plug it in you can go through files just like a regular usb disk, so with the right permissions you can swap files to and from the usb disk.

Hope this helps!

Thanks but this main computer does not have windows only the lap top.

@ijbreakey: the problem is not the method. It’s the mismatch between the recipient filesystem and the filesystem of origin.

@signetone. You’re backing up data that have ownership user=brian group=users to a partition thet has no concept of ownership because Fat32 has no ownerhip facets built into it. It’s world writeable by nature: drwxrwxrwx. Linux attempts to cope with this by imposing fake permissions and fake ownerships. Linux makes it appear in your case that the owner is brian and the group is root and that the permissions are drwxr-xr-x. It’s an illusion, but Linux makes all transactions adhere to that illusion for the duration of time that the device is connected.

So when you try to copy a file that has ownership brian:users and permissions drwx------ to a partition that is being artificially and temporarily constrained to brian:root and drwxr-xr-x, using an instruction (-a) that says “preserve the ownership, permissions and timestamps”, well it won’t work. Hence the error messages.

The solution for you depends on what you are really trying to do. If it’s to make a faithful backup of /home, you must change the format on the usb drive to a Linux format. If it’s to copy the data and media files, no care about or need to maintain the Linux ownership, well you can do that too. So which is it that you want to do?

Here’s how to get the data and media backed up. When the device is not connected, make a directory /media/abc by opening a console window and entering su to become rootly and then entering:

 mkdir /media/abc

Plug in the device. Check it’s gone to some auto mount with these commands:

df -Th

and

fdisk -l

. That should tell you where it’s at. Let’s suppose it attaches as /dev/sdb1. You need to unmount it and then remount it with better permissions. Issue this command:

umount /dev/sdb1

That should unmount it. Then issue this command to remount it:

mount -t vfat -o uid=brian,gid=users,umask=0000,utf8=true /dev/sdb1 /media/abc

That should mount it as brian:users drwxrwxrwx. Now make a directory in there called brian with this command:

mkdir /media/abc/brian

Then you can copy the brian directories over with this:

cp -R /home/brian/. /media/abc/brian/

Note the -R is not as before, -a. That will balk at symbolic links and maybe 1 or two other unimportant things, but it should get all the owner’s files across.

It’s not a precise Linux copy because the permissions are meaningless once the partition is disconnected. And reconnecting it will only produce false, temporary permissions. Thats’ Vfat for you.

Hi

Thanks for your detailed replies.

I will explain what I do and what I am now trying to do. I make a copy of the home information, which I can use on 2 other machines. 2 lap tops running Linux, one Suse 10.2 and the other Suse 11.1. So I use two 8 GB dingles and a 500GB ext hard drive for backing up. I have formatted all with fat32 as I was advised before, as that’s the only way of transferring the data. After transfer I go into the folder and alter all the permissions to allow read and write, as they have been copied as read only. Perhaps I have been doing that incorrectly for 4 years. I now wanted an exact copy of /home [Suse 10.2] as I wanted to dual load Suse 11.1 on same main computer as I know that when it was installed about 4 years ago, there were issues with the video card and printer. I was only going to load Suse 11.1 as Suse 10.2 is no longer supported.

I am a user of the computers and only a newbie as regarding operation. Both the main and IBM laptop have worked with Suse 10.2 with hardly and issues for 4 years, so stable. I did buy a new laptop and loaded Suse 11.1 and use KDE3.5. Share information between computers via the dingles or ext hard drive.

Thanks

If you want to keep using fat32, you will run into trouble on the latest versions of openSUSE where some directories are drwx------. But if you mount the fat32 as drwxrwxrwx owned by brian:users it should be pretty good.

The best I can recommend is to use ext3 as the filesystem. Then you get exact transfer. You can format a dongle to ext3 and you can format part or all of a 500Gb hard drive as ext3.

Unquestionably, ext3 is far better for making copies of /home.

Hi

Thanks for your reply.

If I format to ext3, will I be able to copy to the other computers or run into trouble with permissions? Perhaps I was badly informed when told to use FAT32.

I can try with one 8GB dongle. How do I format it to ext3?
I assume it is text based via the Konsole Terminal program?

Thanks

To create ext3 filesystem on a dongle, first unmount it, then use Yast –> system –> partitioner. Locate the dongle at the bottom of the list. If it has the form sdx then use “Add” to create a filesystem on it – but if it has the form sdx1 then use “Edit” to modify it and format it to ext3.

Of course, it can’t be read in windows but it is perfect for backing up and transferring the directory tree under /home/brian to other Linux machines.

[PS if you install the ext2 driver on windows, then windows can read a dongle formatted in ext3.]

Hi

Thanks for the reply.

In My Computer the Dongle is given the option Safely Remove instead of Unmount?

I think that will unmount it.
Here’s how you can check if “safely remove” is the same as unmount: Run the command: df -Th, then “safely remove” the device, then run the command again to see whether it’s gone from the return dialogue.

Hi

Yes exactly right. Then the partitioner does not see it?

Sorry about this…