Skip to content

Instantly share code, notes, and snippets.

@hallahan
Created February 3, 2016 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hallahan/e69c691ca54000af4481 to your computer and use it in GitHub Desktop.
Save hallahan/e69c691ca54000af4481 to your computer and use it in GitHub Desktop.
Backup and Restore a Linux Installation on NUC

Fresh Ubuntu Server Install

Created a tar.gz inside when booted up into a USB Xubuntu.

sudo tar -cvpzf fresh-ubuntu-server.tar.gz --one-file-system /media/xubuntu/cea0fa37-84bc-4edb-8ce1-0fac03b717db/

To restore the system to this archive, you want to reformat the system partition. Unmount the /media. Figure out which /dev/sda* is the system partition:

sudo parted /dev/sda print
Model: ATA Samsung SSD 850 (scsi)
Disk /dev/sda: 250GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system     Name    Flags
 1      1049kB  538MB   537MB   fat32                   boot
 2      538MB   20.5GB  20.0GB  ext4            system
 4      20.5GB  242GB   221GB   ext4            data
 3      242GB   250GB   8506MB  linux-swap(v1)  swap

For us it is /dev/sda2.

Also, df -h helps us figure out what is currently mounted.

xubuntu@xubuntu:/dev$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/cow            3.9G   63M  3.8G   2% /
udev            3.9G  4.0K  3.9G   1% /dev
tmpfs           791M  1.4M  790M   1% /run
/dev/sdb        949M  949M     0 100% /cdrom
/dev/loop0      908M  908M     0 100% /rofs
none            4.0K     0  4.0K   0% /sys/fs/cgroup
tmpfs           3.9G  8.0K  3.9G   1% /tmp
none            5.0M  4.0K  5.0M   1% /run/lock
none            3.9G   80K  3.9G   1% /run/shm
none            100M   24K  100M   1% /run/user
/dev/sda2        19G  1.5G   16G   9% /media/xubuntu/cea0fa37-84bc-4edb-8ce1-0fac03b717db

Reformat /dev/sda2.

sudo mkfs -t ext4 /dev/sda2

Now, we want to uncompress our archive into this fresh partition:

cd /media/xubuntu/7bb41b72-c321-4a32-bbe9-c97364a5d43e/backups
sudo tar -xvpzf ./fresh-ubuntu-server.tar.gz -C /media/xubuntu/7c7179f0-a405-443a-bead-42133690b716/ --numeric-owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment