JP Vossen on 13 Oct 2017 20:20:44 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Things to correct when copying over a filesystem with rsync?


If you are duplicating the machine you want to grab more than if you're just copying data. You almost certainly don't want to sync /cdrom/, /dev/, /media/, /mnt/, /proc/, or /sys/. You can exclude things or only include the ones you want. You need to re-create those "missing" dirs with the correct owner and perms too.

/etc/fstab is a big one, as are the files Fred listed, and/or:
	/etc/network/interfaces
	/etc/udev/rules.d/70-persistent-net.rules

Then as we talked about (different syntax):
	Mount everything up as needed under /mnt/ or someplace
	mount --bind /dev/ mnt/dev
	mount --bind /dev/pts mnt/dev/pts
	mount --bind /proc mnt/proc
	mount --bind /sys mnt/sys
	chroot /mnt
	update-grub
	reboot


Some of the options I like for rsync are:
time rsync --verbose --rsh='ssh' --numeric-ids --archive --hard-links --acls --xattrs --sparse --one-file-system --stats --human-readable

Others:
	--progress		(noisy)
	--itemize-changes	(noisy)
	--delete
	--remove-source-files	<<< AWESOME

Here's an rsync command I did recently to duplicate a machine:
time rsync --rsh='ssh' --numeric-ids --archive --xattrs --hard-links --one-file-system --verbose --progress --sparse --stats --human-readable /bin /boot /etc /home /initrd.img* /lib /lib64 /opt /root /run /sbin /srv /usr /var /vmlinuz* root@192.168.10.10:/mnt

The target was booted from a LiveDVD and had disks formatted and mounted as desired in target:/mnt/. Afterwards you have to do something like:
	mkdir /cdrom /dev /media /mnt /proc /sys
	chmod 0755 /cdrom /dev /media /mnt
	chmod 0555 /proc /sys

Side note: --remove-source-files is awesome when you have to "upload" files someplace else. You just rsync an upload queue dir and let it figure out when the files safely make it to the other side. No fuss, no muss, no race conditions, and 20 years of extensive testing.


On 10/13/2017 05:48 PM, Fred Stluka wrote:
Don't forget to update any files that contain the IP address or the
host name.  Typically:
- /etc/sysconfig/network
- /etc/hosts
- /etc/tripwire/twpol.txt

On 10/13/17 2:15 PM, Keith C. Perry wrote:
The only thing I usually have to "fix" are the UUIDs in the fstab and the grub config- using grub-mkconfig and grub-install generically speaking.  Some systems hide those behind other tools.

You might have to rebuild your initrd but if you're getting to the point where you can boot and just change fstab entries you don't need to do that either.

----- Original Message -----
From: "Greg Helledy"<gregsonh@gra-inc.com>
To: "Philadelphia Linux User's Group Discussion List"<plug@lists.phillylinux.org>
Sent: Friday, October 13, 2017 1:44:58 PM
Subject: [PLUG] Things to correct when copying over a filesystem with rsync?

As a followup to my posting from earlier in the week:
I decided to get us away from LVM by installing the OS on a new pair of
drives (RAID-1), configuring everything identically, then bringing over
other third-party software by copying the entire filesystem with rsync.

There are two partitions, /boot and /.  No user software should be in
/boot and copying that would surely screw things up so I just copied the
other partition.  One rookie mistake I made was failing to back up
/etc/fstab, because of the UUIDs.  So I used a rescue CD to go in and
restore the correct values.

I can't think of anything else that would be similar:  two installed
OSes, identical in every way except for the hard drives they reside on.
If you overwrite one with the other, are there any config files that
refer to the hard drive hardware, not on the /boot partition, which will
cause a problem?
Later,
JP
--  -------------------------------------------------------------------
JP Vossen, CISSP | http://www.jpsdomain.org/ | http://bashcookbook.com/
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug