Hello everyone, how are you all doing today? I hope you are all having a great start to 2020! Wow, what a year 2019 was and lets hope 2020 will be fair and progressive for all of us on this planet.
Today to celebrate the start of a new year, we will feature a quick guide that will teach you how to backup your files on Ubuntu using the terminal and typing some simple commands. This tutorial is perfect for anyone who wants to quickly backup their folders, music and other apps in a .zip/.tar formats in Linux. Let us begin.
Backup Files Commands On Ubuntu
There’s is some tools you can use to backup your entire system or your most important files. tar
, gzip
, bzip2
, dump
and rsync
are some tools you can use to backup files and folders. automysqlbackup
is a tool to backup your MySQL databases.
Example backup
Here’s an example of a folder backup including all the sub-folders and files within.
tar -cvf archive-name.tar dir1 dir2 dir3....
Now, let’s compress it:
gzip -9 archive-name.tar
You can use bzip2
instead. bzip2 has a better compression rate but is a little slower.
To combine both command, you can use the -z
option.
Ubuntu Dump Command
dump
is written specifically for backups. It backs up the entire file system and allows multiple levels of backups. The corresponding restore
command allows for restore from a dump backup.
For example, to backup /boot file system:
dump 0zf backup.boot /boot
Ubuntu MySQL Backup Command
There’s an easy command to backup MySQL databases. automysqlbackup
can automatically make daily, weekly, and monthly backups of your MySQL database.
Install
sudo aptitude install automysqlbackup
Configure Backup
sudo vi /etc/default/automysqlbackup
All the backup are stored in the /var/lib/automysqlbackup
by default. It is recommended to change this folder. To change the default backup folder, edit the file and modify the
BACKUPDIR=
to the new location.
You can also receive an email if there’s an error while running the backup. To do this, you need to change the MAILADDR=
and add your email address.
Backup Ubuntu Home Folder
You can backup your entire home folder using the zip
command. If you want to exclude some folder, you need to use the –exclude
parameter.
zip -r myzipbackup.zip * --exclude=access_log --exclude=public_ftp --exclude=tmp
Ubuntu Backup Help & References Links
Other tutorials and Linux guides: How To Update Ubuntu, How To Stop A DDOS Attack, Ubuntu Server Guide