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

Re: sync apt/dpkg state between systems?

I should say a few more words about how to restore.

Bob Proulx wrote:
> * Restore whatever of ...

When I said "restore" I would probably use the 'rsync' tool.  You said
you had the files available.  I would use rsync to copy those files
from the backup area to the live area.  After doing the small system
install I would then install rsync and use it to restore the files
from the backup.

For example if /mnt/backup contains files that are available from
the old system then I would use a command like this one to restore
files from it.

  # rsync -av /mnt/backup/etc/ /etc/
  # rsync -n --delete -av /mnt/backup/etc/ /etc/
  # rsync --delete -av /mnt/backup/etc/ /etc/

It is important that the trailing slashes be included in both
parameters.  That will map those two directories to each other
exactly.  A common error is to say:

  # rsync -av /mnt/backup/etc /etc

That would find that the target is a directory and so would copy the
source into a directory on the target and you would get /etc/etc
instead of what you wanted.

Alternatively always specify the parent directory on the right hand
side as the target.  This is also correct and will match the backup
directory with the target.  Either way.  These next two commands are

  # rsync -av /mnt/backup/etc /
  # rsync -av /mnt/backup/etc/ /etc/

And when deleting I always like to review what would be deleted before
I do so.  The answer may be surprising and inform me that I need to
react and do something different.  Therefore I always examine what
would be deleted without actually doing it with the -n (not really)
option first.  Then if it seems reasonable only then do I proceed with
the actual deletion.

  # rsync -n --delete -av /mnt/backup/etc/ /etc/
  # rsync --delete -av /mnt/backup/etc/ /etc/

When restoring and syncing directories removing extra files is just as
important as copying the exiting files.  Because you may have actively
removed files as part of the previous configuration.  Only by doing
the -n --delete operation as well will you truly know if the restored
copy is identical to the backup.  Because a pristine installation may
install extra files that you have removed.

Or you may find that you had previously broken something.  Then
instead of removing a file you might decide that you should learn from
this information and fix it.  Always a good thing to catch previous
problems and fix them.  :-)


Attachment: signature.asc
Description: Digital signature

Reply to: