====== Ubuntu - Backups - Backup using tar ======
**ALERT:** Double check that all paths are written correctly!!!
* If not, then this may result in an unrecoverable system and data loss.
----
===== Backup =====
# tar.gz
tar cvpzf os_backup.tar.gz / --exclude=/proc --exclude=/lost+found --exclude=/os_backup.tar.gz --exclude=/mnt --exclude=/sys
# tar.bz2
tar cvpjf os_backup.tar.bz2 / --exclude=/proc --exclude=/lost+found --exclude=/os_backup.tar.bz2 --exclude=/mnt --exclude=/sys
----
===== Restore =====
cd /
# Copy the os_backup.tar.gz or os_backup.tar.bz2 to the root directory.
then
# For tar.gz
tar xvpfz system_backup.tar.gz -C /
or
# For tar.bz2
tar xvpfj system_backup.tar.bz2 -C /
----
===== Create directories that were not backed up =====
mkdir proc
mkdir lost+found
mkdir mnt
mkdir sys
----
===== Modify directory permission =====
chown -R root:root /proc/
chown -R root:root /lost+found/
chown -R root:root /mnt/
chown -R root:root /sys/
chmod -R 555 /proc/
chmod -R 700 /lost+found/
or
chmod -R 755 /lost+found/
chmod -R 755 /mnt/
chmod -R 755 /sys/
----