dark

How to backup and Reset Ubuntu Server to Default Settings

Ubuntu Server is an open-source operating system that runs server applications, including web servers, database servers file servers, and many more. it is the more reliable operating system for your Server. We will have a look at ways to back up data in the ubuntu server as well as how to restore to its default settings.

Before we look at how to back up and reset, here are some reasons technical guys prefer the Ubuntu server.

  1. Reliability: it is a stable and reliable operating system, with regular security updates and bug fixes.
  2. Security: it inbuilt with several security features, such as AppArmor and firewalls, to help secure your server.
  3. Compatibility: Supports a wide range of hardware and software, making it easy to use with your existing server infrastructure without spending extra money getting resources.
  4. Ease of use: it has a user-friendly command-line interface and can be easily managed using tools like apt-get and Ubuntu Server GUI.
  5. Cost: acquiring the ubuntu server operating system is free and open-source, making it a cost-effective solution for server use.

How to backup data on Ubuntu Server.

Ubuntu Server backup can be done using two options, one is through manually copying the files to an external storage device .it is a simple process through not always recommended to be used in handling large amounts of data or used in data that require to be backed up frequently

the other way of doing back up is to use tar command so as to come up with a tar archive of the data and the directories. it is recommended to implement this method, especially when handling large amounts of data and those that often require backing up. When the tar command is used the archive is compressed hence saving space. the command used is below:

tar -cvzf /path/to/backup.tar.gz /path/to/data

the other command that is important when doing a backup is using the rsync , this will allow you to synchronize files and directories to an external directory, Usually what gets transferred during syncing is the changes in files or directories. this command is recommended when doing real-time backup

rsync -avz /path/to/data/ /path/to/backup/

Reset Ubuntu Server to Default Settings

  • Boot the Server into recovery mode, this you will achieve by restarting the server and then holding down the shift key as it is booting up, the boot menu will appear with an option to choose the recovery mode.
  • proceed to the root shell once the ubuntu server has finished booting into recovery mode, by selecting the “root shell” option
  • we will now move and remove the packages and configuration files, anything that was installed after initial installation will be cleared. the command that will be used is as below,
dpkg --get-selections | grep -v deinstall | awk '{print $1}' | xargs apt-get --purge -y remove
  • If you wish to reset including the account user and password, you will run the below command
cat /dev/null > /etc/shadow

Once all the above commands are executed proceed to reboot the server using the below command

reboot

Give time for the server to reboot, once it booted up the ubuntu server will now be in its default state with all packages and the configuration files it had cleared. The Method explained here only assists us to reset our ubuntu server to the default state but does not do a full operating system reinstallation

In case you would like to proceed and do clean up the ubuntu server disk to free up more space the below command will be used;

find / -name "*.bak" -type f -delete
find / -name "*.backup" -type f -delete
find / -name "*.old" -type f -delete

All the packages and configuration files will be cleared from your ubuntu server. If you would like to proceed and do the reinstallations of the removed packages here are the commands to use;

apt-get update
apt-get upgrade

from running the above commands the package lists will be downloaded and in case of any outdated package it will be updated to the latest version

conclusion

Ubuntu server is one of the best choices, user-friendly, and saves on cost operating system which meets most of our day-to-day needs from personal to organizations.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts