1

Instead of using Ansible or some other configuration management tool, after many months of being the admin of this ubuntu 16.04 server, I made a lot of changes to the system: changed config files in /etc, installed packages, enabled and disabled apache2 modules, and so on.

Is there an automated way to create a script or something, that when executed on a clean installation of ubuntu 16.04 (but if it works on any linux even better), can recreate a server that is more or less exactly the same as the one I have right now and is working and running?

Edit: Unfortunately this is not a VM I can just clone.

4
  • Is this a physical server or virtual machine?
    – ryekayo
    Oct 12, 2017 at 20:58
  • @ryekayo it's a virtual machine hosted on a hosting provider. I don't have access to the kvm admin interface, so I can't just clone it.
    – Simon
    Oct 12, 2017 at 20:59
  • I was going to suggest, easiest thing to do would be to create a snapshot/template based on your VM. That way, going forward you can spin up new servers with that template
    – ryekayo
    Oct 12, 2017 at 21:00
  • @ryekayo unfortunately not an option in this case
    – Simon
    Oct 12, 2017 at 21:01

2 Answers 2

1

There's not much you can do when it comes to industry standards right now. If you really need scripts to prepare everything for you then I would :

  • dump all installed packages with dpkg -l along with versions of it.
  • create a new server with ubuntu 16.04, install all the packages in the same versions.
  • install etckeeper on the new server
  • rsync all the /etc directories from the original server to the "clean" one - ensuring that the files from the "clean" one that aren't present in the original one are deleted ( a2dismod simply deletes symlinks in /etc/apache2/modules-enabled directory so it would be another way of doing the same) - there is an option in rsync to do just that.

After that is done you should be presented (thanks to etckeeper) with a git differential of the /etc/ directory - this can simply(?) be transformed into a patch script - but it will only work reliably when all package versions will be exactly the same as the original server. This would be however a good base for some real templates for ansible / puppet / chef

Going down that route you should be able to create some kind of automation to prepare new servers with similiar configuration.

There is another option if "industry standards" do not concern you - just rsync / tar the whole server (you need to stop the databases, or omit them in the rsync to avoid inconsistent file structures ) so you can unpack it over a clean install of ubuntu 16.04 to get exactly the same machine in another location.

0

The only approaches I can think are:

  • find the list of all installed packages and reinstall them on the target machine; then find all the changed/added configuration files and use tar/rsync/whatever to copy them on the target machine;

  • if you can't/won't clone by direct RAW copy, you can use tar/rsync (with appropriate parameters) to completely clone the source data to the new machine.

  • you can use a filesystem dump tool (ie: dump2fs, xfsdump, fsarchiver, etc) to dump the entire filesystem, restoring it on the new machine;

  • use clonezilla/dd/ddrescue to clone the physical disks (cloning does not need a virtual environment at all) and restore the image on the target machine. This require a livecd-booted source machine or a LVM/BTRFS/ZFS snapshot of the source volume.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .