Difference between pages "Zero Configuration Networking" and "Rsync Backup"

(Difference between pages)
 
(Created page with "== Introduction ==This tutorial leads you through the process of backuping and restoring your OS. This process is completed using the <code>rsync</code> tool that is included ...")
 
Line 1: Line 1:
Zero Configuration Networking, also called Zeroconf or [[wikipedia:Bonjour_(software)|Bonjour]]  ([http://developer.apple.com/softwarelicensing/agreements/bonjour.html Apple's trademark] for their Zero Configuration Networking implementation) is a suite of related technologies that allow networked devices to interoperate on a local network without requiring explicit configuration.
+
== Introduction ==This tutorial leads you through the process of backuping and restoring your OS. This process is completed using the <code>rsync</code> tool that is included in SystemRescueCd.== Why SystemRescueCd ==The usage of SystemRescueCD is quite simple: it enables us to backup the contents of our entire OS.== Backing Up ===== Preparation ===By default SystemRescueCd provides a <tt>/mnt/backup</tt> mount point. We will use this. There is no mount point for Funtoo. We have to create one:<console>###i## install -d /mnt/funtoo</console>When you use SystemRescueCd to backup you OS for the first time, you also have to create mount points for additional partitions. In this tutorial we assume that there is a <tt>/boot</tt> and a <tt>/home</tt> partition. Create the directories in <tt>/mnt/funtoo</tt>: <console>###i## install -d /mnt/funtoo/boot###i## install -d /mnt/funtoo/home</console>We also assume that we are backing up a sytem to an external drive. Plug in the USB device and power it on.<console>###i## cat /proc/partitionsmajor minor  #blocks  name  8        0  488386584 sda  8        1    512000 sda1  8        2      32768 sda2  8        3    2097152 sda3  8        4  52428800 sda4  8        5  433314823 sda5  8      16  488386584 sdb  11        0    1048575 sr0  8      48  488386584 sdd  8      49  229032928 sdd1  8      52          1 sdd4  8      53  259352576 sdd5</console>The above command helps you to determine the device name. Lets's suppose that your backup device is <tt>/dev/sdd1</tt>. Mount the device now - along with your Funtoo partitions.<console>###i## mount /dev/sdd1 /mnt/backup###i## mount /dev/sda4 /mnt/funtoo###i## mount /dev/sda5 /mnt/funtoo/home###i## mount /dev/sda1 /mnt/funtoo/boot</console>=== Backup ===Now, we backup our Funtoo partition:<console>###i## rsync -aHA --del --force --stats --progress /mnt/funtoo /mnt/backup</console>=== Snapshot ===Once this command has completed, you can create a snapshot. Create a snapshot folder if there is none:<console>###i## install -d /mnt/backup/snapshot</console>Give your snapshot copy a name that includes the date. Thus, you may keep as many snapshot copies as you want and use one of those copies to restore your system to its state at any given date:<console>###i## cp -al /mnt/backup/funtoo /mnt/backup/snaphot/snap-2K014B26-a</console>{{fancynote| In our example, the name of the snapshot tells us that it was created on February 26th (B26) 2014 and it is the first one (a) made on that date. }}=== Log of backups ===Logging backups is not mandatory but could be useful. Create a log file and add a descriptive yet short record for each of your backup. Here is an example:<pre>Date                File                  Description-----------------    --------------------  ----------------------------------------------------------Feb 26th 2014        snap-2K014B26-a       Backup after system update :                                            - New kernel installed</pre>== Restoring ==First, you have to boot the PC with SystemRescueCd. When you are ready to go, create and format partitions as per [[Funtoo_Linux_Installation#Prepare_Hard_Disk|installation guide]]. For sake of brevity we assume that we are restoring the <tt>/boot</tt>, <tt>/</tt> and <tt>/home</tt> partitions. First, you must create a mount point for Funtoo:<console>###i## install -d /mnt/funtoo</console>=== Mount partitions ===<console>###i## mount /dev/sdd1 /mnt/backup###i## mount /dev/sda4 /mnt/funtoo###i## mount /dev/sda5 /mnt/home###i## mount /dev/sda1 /mntboot</console>{{fancywarning|If <tt>/home</tt> and <tt>/boot</tt> fail to mount, simply create mount points and run mount commands anew.}}=== Restoring from latest backup ===<console>###i## rsync -aHA --del --force --stats --progress /mnt/backup/funtoo/ /mnt/funtoo</console>{{fancyimportant|Note the <tt>/</tt> at the end of <code>/mnt/backup/funtoo/</code>. It is mandatory -- not a typo.}}=== Restoring from a previous backup ===<console>###i## rsync -aHA --del --force --stats --progress /mnt/backup/snapshot/snap-2K014B26-a/ /mnt/funtoo</console>{{fancyimportant|Note the '''<tt>/</tt>''' at the end of <code>/mnt/backup/snapshot/snap-2K014B26-a/</code>. It is mandatory -- not a typo.}}=== Restoring GRUB2 ===Once the system has been restored, GRUB2 must be reinstalled. The example below is for a GRUB/Bios partition schema. This assumes that the Funtoo partitions were created on <tt>/dev/sda</tt>:<console>###i## cd /mnt/funtoo###i## mount -t proc none proc###i## mount -o bind /dev dev###i## mount -o bind /sys sys###i## swapon /dev/sda3###i## cp /etc/resolv.conf etc###i## env -i HOME=/root TERM=$TERM chroot . bash -l###i## grub-install /dev/sda</console>{{fancywarning|If, for any reason, partitions were not created on the same devices -- (let's say they were moved from <tt>/dev/sda</tt> to <tt>/dev/sdb</tt>) -- please amend <code>/etc/boot.conf</code> and <code>/etc/fstab</code> accordingly before running <code>boot-update</code>.}}<console>###i## boot-update</console>You're done. Unmount partitions and reboot.== Credit ==This is an as-is translation by Guy Fontaine (AKA Aramis_qc) of an original French tutorial written by Sylvain Alain (AKA d2_racing). Some parts were reviewed and modified to reflect Funto GNU/Linux instead of Gentoo GNU/Linux. [[Category:HOWTO]]
 
+
== Requirements ==
+
 
+
Zero Configuration Networking requires the following things to operate:
+
 
+
* A valid IP address, obtained either by:
+
** Static assignment
+
** DHCP
+
** Link-local Addressing (part of Zero Configuration Networking)
+
* A means to address other devices by name, provided either by:
+
** DNS
+
** multicast DNS (mDNS -- part of Zero Configuration Networking)
+
 
+
== Service Discovery ==
+
 
+
On top of this, Zero Configuration Networking also provides a means to discover what services are available on each device. This is something that is provided exclusively by Zero Configuration Networking and is called Zeroconf Service Discovery.
+
 
+
== Configuration ==
+
 
+
In order to get these sort of networking services running, some configuration needs to happen initially.
+
 
+
== Link-local Addresses ==
+
 
+
{{Fancynote|It's only necessary to use link-local addressing if you have no other means of obtaining a valid IP address on your LAN. Typically, this is the case if you are setting up a small or ad-hoc network where no DHCP server has been configured.}}
+
 
+
To use link-local addressing, first set up the proper routes:
+
<console>
+
###i## route add default dev eth0 metric 99
+
###i## route add -net 169.254.0.0 netmask 255.255.0.0 dev eth0 metric 99
+
</console>
+
 
+
Then, use avahi-autoipd to discover a valid link-local IP address:
+
<console>
+
###i## /usr/sbin/avahi-autoipd --daemonize --syslog --wait eth0
+
</console>
+
 
+
Once a valid link-local IP address is found, eth0 will now have a 169.254.x.x address that can be used to communicate on the local LAN.
+
 
+
As an alternative, you can have dhcpcd built with <code>USE="zeroconf"</code>, and it will provide a link local address if no DHCP server is found.
+
 
+
== Multicast DNS ==
+
 
+
Multicast DNS, or mDNS, is a means by which individual machines can broadcast their DNS information to machines on the local LAN so that a DNS server is not required to address local devices by name. The ".local" domain is typically used for multicast DNS, so your laptop might be addressable by pinging "mylaptop.local", for example. mDNS is not necessary if you have some other means of addressing machines by name, such as unicast (regular) DNS. But many LANs do not have their own DNS server configured, in which case mDNS can be very handy.
+
 
+
=== .local Hostname Suffix ===
+
 
+
If you want to configure your Funtoo Linux system to be addressable on your LAN using a <tt>myhostname.local</tt> address, first ensure that you set your system's hostname in <tt>/etc/conf.d/hostname</tt>, and use ''only'' the non-qualified name, so don't add a <tt>.local</tt> yourself. Multicast DNS will automatically use that suffix. Here is a sample <tt>/etc/conf.d/hostname</tt> for a machine on my network that I can ping from other machines as <tt>antec.local</tt>:
+
 
+
{{File
+
|/etc/conf.d/hostname|<pre>
+
hostname="antec"
+
</pre>}}
+
 
+
== Receiving mDNS ==
+
 
+
The ebuild "nss-mdns" provides the necessary functionality for your Funtoo/Gentoo Linux machine to receive mDNS broadcasts, so that it can do things like ping mybox.local, or ssh mylaptop.local.
+
 
+
From the [http://0pointer.de/lennart/projects/nss-mdns/#overview nss-mdns] home page:
+
 
+
''nss-mdns is a plugin for the GNU Name Service Switch (NSS) functionality of the GNU C Library (glibc) providing host name resolution via Multicast DNS (aka Zeroconf, aka Apple Rendezvous, aka Apple Bonjour), effectively allowing name resolution by common Unix/Linux programs in the ad-hoc mDNS domain .local.
+
 
+
''nss-mdns provides client functionality only, which means that you have to run a mDNS responder daemon seperately from nss-mdns if you want to register the local host name via mDNS. I recommend Avahi.
+
 
+
''nss-mdns is very lightweight (9 KByte stripped binary .so compiled with -DNDEBUG=1 -Os on i386, gcc 4.0), has no dependencies besides the glibc and requires only minimal configuration.
+
 
+
''By default nss-mdns tries to contact a running avahi-daemon for resolving host names and addresses and making use of its superior record cacheing. Optionally nss-mdns can be compiled with a mini mDNS stack that can be used to resolve host names without a local Avahi installation. Both Avahi support and this mini mDNS stack are optional, however at least one of them needs to be enabled. If both are enabled a connection to Avahi is tried first, and if that fails the mini mDNS stack is used.
+
<console>
+
###i## emerge -av nss-mdns
+
</console>
+
 
+
Set up multicast route:
+
<console>
+
###i## route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0
+
</console>
+
 
+
Note: Adding <code>multicast="yes"</code> in <code>/etc/conf.d/netif.foo</code> (replace foo with your actual network interface name) will set up the multicast route automatically at startup.
+
 
+
Now, it's necessary to modify <tt>/etc/nsswitch.conf</tt> so that your system will use multicast DNS for hostname lookup. In the example, we use the <tt>mdns_minimal</tt> and <tt>mdns</tt> words, which enable multicast DNS for IPv4 and IPv6. If you only want to enable IPv4-based multicast DNS, which is recommended for IPv4-only networks, use <tt>mdns4_minimal</tt> and <tt>mdns4</tt> instead. This will improve hostname lookup performance.
+
{{File
+
|/etc/nsswitch.conf|<pre>
+
hosts:      files mdns_minimal [NOTFOUND=return] dns mdns
+
</pre>}}
+
 
+
== Sending Multicast DNS ==
+
 
+
Avahi-daemon handles the task of '''sending''' multicast DNS broadcasts, as well as service discovery broadcasts, on your local LAN. If you want other devices to be able to reach your Funtoo/Gentoo Linux machine via multicast DNS, and Zeroconf Service Discovery, you'll want to enable avahi-daemon. This will also improve the efficiency of performing multicast DNS lookups locally.
+
 
+
<console>
+
###i## rc-update add avahi-daemon default
+
###i## rc
+
</console>
+
 
+
Test:
+
<console>
+
###i## ping daniel-pc.local
+
PING daniel-pc.local (10.0.1.11) 56(84) bytes of data.
+
64 bytes from Daniel-PC.local (10.0.1.11): icmp_req=1 ttl=128 time=3.73 ms
+
64 bytes from Daniel-PC.local (10.0.1.11): icmp_req=2 ttl=128 time=0.905 ms
+
64 bytes from Daniel-PC.local (10.0.1.11): icmp_req=3 ttl=128 time=0.922 ms
+
64 bytes from Daniel-PC.local (10.0.1.11): icmp_req=4 ttl=128 time=0.827 ms
+
</console>
+
 
+
== Service Discovery ==
+
 
+
Get a list of services on the LAN:
+
<console>
+
###i## avahi-browse -ac
+
</console>
+
 
+
== Resources ==
+
 
+
* [http://developer.apple.com/library/mac/#qa/qa2004/qa1357.html Apple Technical Q&A QA1357]
+
* [http://en.gentoo-wiki.com/wiki/Avahi Gentoo Wiki Avahi]
+
* [http://www.ibiblio.org/pub/linux/docs/HOWTO/other-formats/html_single/Multicast-HOWTO.html#toc2 Multicast over TCP/IP HOWTO]
+
* [http://sitka.triumf.ca/pub/linux/multicast-FAQ Linux Multicast FAQ]
+
* [http://www.multicastdns.org/ multicastdns.org]
+
 
+
+
[[Category:HOWTO]]
+
[[Category:Networking]]
+

Revision as of 15:28, March 2, 2014

== Introduction ==This tutorial leads you through the process of backuping and restoring your OS. This process is completed using the rsync tool that is included in SystemRescueCd.== Why SystemRescueCd ==The usage of SystemRescueCD is quite simple: it enables us to backup the contents of our entire OS.== Backing Up ===== Preparation ===By default SystemRescueCd provides a /mnt/backup mount point. We will use this. There is no mount point for Funtoo. We have to create one:
# install -d /mnt/funtoo
When you use SystemRescueCd to backup you OS for the first time, you also have to create mount points for additional partitions. In this tutorial we assume that there is a /boot and a /home partition. Create the directories in /mnt/funtoo:
# install -d /mnt/funtoo/boot###i## install -d /mnt/funtoo/home
We also assume that we are backing up a sytem to an external drive. Plug in the USB device and power it on.
# cat /proc/partitionsmajor minor  #blocks  name   8        0  488386584 sda   8        1     512000 sda1   8        2      32768 sda2   8        3    2097152 sda3   8        4   52428800 sda4   8        5  433314823 sda5   8       16  488386584 sdb  11        0    1048575 sr0   8       48  488386584 sdd   8       49  229032928 sdd1   8       52          1 sdd4   8       53  259352576 sdd5
The above command helps you to determine the device name. Lets's suppose that your backup device is /dev/sdd1. Mount the device now - along with your Funtoo partitions.
# mount /dev/sdd1 /mnt/backup###i## mount /dev/sda4 /mnt/funtoo###i## mount /dev/sda5 /mnt/funtoo/home###i## mount /dev/sda1 /mnt/funtoo/boot
=== Backup ===Now, we backup our Funtoo partition:
# rsync -aHA --del --force --stats --progress /mnt/funtoo /mnt/backup
=== Snapshot ===Once this command has completed, you can create a snapshot. Create a snapshot folder if there is none:
# install -d /mnt/backup/snapshot
Give your snapshot copy a name that includes the date. Thus, you may keep as many snapshot copies as you want and use one of those copies to restore your system to its state at any given date:
# cp -al /mnt/backup/funtoo /mnt/backup/snaphot/snap-2K014B26-a

Note

In our example, the name of the snapshot tells us that it was created on February 26th (B26) 2014 and it is the first one (a) made on that date. 
=== Log of backups ===Logging backups is not mandatory but could be useful. Create a log file and add a descriptive yet short record for each of your backup. Here is an example:
Date                 File                  Description-----------------    --------------------  ----------------------------------------------------------Feb 26th 2014        snap-2K014B26-a       Backup after system update :                                             - New kernel installed
== Restoring ==First, you have to boot the PC with SystemRescueCd. When you are ready to go, create and format partitions as per installation guide. For sake of brevity we assume that we are restoring the /boot, / and /home partitions. First, you must create a mount point for Funtoo:
# install -d /mnt/funtoo
=== Mount partitions ===
# mount /dev/sdd1 /mnt/backup###i## mount /dev/sda4 /mnt/funtoo###i## mount /dev/sda5 /mnt/home###i## mount /dev/sda1 /mntboot

Warning

If /home and /boot fail to mount, simply create mount points and run mount commands anew.

=== Restoring from latest backup ===
# rsync -aHA --del --force --stats --progress /mnt/backup/funtoo/ /mnt/funtoo

Important

Note the / at the end of /mnt/backup/funtoo/. It is mandatory -- not a typo.

=== Restoring from a previous backup ===
# rsync -aHA --del --force --stats --progress /mnt/backup/snapshot/snap-2K014B26-a/ /mnt/funtoo

Important

Note the / at the end of /mnt/backup/snapshot/snap-2K014B26-a/. It is mandatory -- not a typo.

=== Restoring GRUB2 ===Once the system has been restored, GRUB2 must be reinstalled. The example below is for a GRUB/Bios partition schema. This assumes that the Funtoo partitions were created on /dev/sda:
# cd /mnt/funtoo###i## mount -t proc none proc###i## mount -o bind /dev dev###i## mount -o bind /sys sys###i## swapon /dev/sda3###i## cp /etc/resolv.conf etc###i## env -i HOME=/root TERM=$TERM chroot . bash -l###i## grub-install /dev/sda

Warning

If, for any reason, partitions were not created on the same devices -- (let's say they were moved from /dev/sda to /dev/sdb) -- please amend /etc/boot.conf and /etc/fstab accordingly before running boot-update.

# boot-update
You're done. Unmount partitions and reboot.== Credit ==This is an as-is translation by Guy Fontaine (AKA Aramis_qc) of an original French tutorial written by Sylvain Alain (AKA d2_racing). Some parts were reviewed and modified to reflect Funto GNU/Linux instead of Gentoo GNU/Linux.