learn how to back up your system to another remote Linux system<\/a> if you’d prefer in a different tutorial. <\/p>\n\n\n\nKeep reading to learn how to make a local backup.<\/p>\n\n\n\n
Unmount, Format, and Remount the External Device<\/h3>\n\n\n\n First, insert your external USB drive and take note of its SCSI ID. This can be done with different external devices as well. In the output, we can see it is labelled sdb<\/code>.The complete SCSI ID for the device is \/dev\/sdb\/ <\/code>and it is currently mounted on the \/media\/jumpcloud\/USB<\/code> mount point.<\/p>\n\n\n\n <\/figure>\n\n\n\nTo use the USB drive as a backup destination, we need to format it to the ext4 <\/code>filesystem. To achieve this, we will first unmount it.<\/p>\n\n\n\n$ sudo unmount \/dev\/sdb <\/code><\/p>\n\n\n\nOnce unmounted, format the external drive to ext4 <\/code>filesystem using the mkfs <\/code>command as follows:<\/p>\n\n\n\n$ sudo mkfs.ext4 \/dev\/sdb<\/code><\/p>\n\n\n\nNext, we are going to mount it back so the Linux system can detect it. To do so, we will create a mount point called \/backup<\/code> as follows. This is simply an arbitrary name and you are free to name it as you wish.<\/p>\n\n\n\n$ sudo mkdir \/backup<\/code><\/p>\n\n\n\nThen mount the external drive to the mount point created.<\/p>\n\n\n\n
$ sudo mount \/dev\/sdb \/backup<\/code><\/p>\n\n\n\nVerify the Device is Mounted<\/h3>\n\n\n\n You can verify the drive is mounted using the df<\/code> command as follows:<\/p>\n\n\n\n$ df -Th | grep sd<\/code><\/p>\n\n\n\n <\/figure>\n\n\n\nTest Run the Backup<\/h3>\n\n\n\n At this juncture, we are ready to begin the backup. It\u2019s always recommended to test the backup before running the real backup. Remember, an untested backup is as good as no backup at all.<\/strong><\/p>\n\n\n\nTo carry out a test run, navigate to the root (\/<\/code>) directory.<\/p>\n\n\n\n$ cd \/<\/code><\/p>\n\n\n\nNext, run the command:<\/p>\n\n\n\n
$ sudo rsync -aAXv \/ –dry-run \u2013-delete –exclude={\/dev\/*,\/proc\/*,\/sys\/*,\/tmp\/*,\/run\/*,\/mnt\/*,\/media\/*,\/cdrom\/*,\/lost+found} \/backup<\/code><\/p>\n\n\n\nLet us quickly go over the command options:<\/p>\n\n\n\n <\/figure>\n\n\n\nsudo <\/code>\u2013 This allows you to execute the command as the root user or superuser.<\/p>\n\n\n\nrsync<\/code> \u2013 This is the backup program itself.<\/p>\n\n\n\n-a <\/code>\u2013 Archive mode.<\/p>\n\n\n\n-A<\/code> \u2013 This preserves the Access Control List.<\/p>\n\n\n\n-X<\/code> \u2013 This preserves all extended file attributes of the files.<\/p>\n\n\n\nThe last three options allow you to preserve all of your files’ attributes. During the backup process, no permissions or ownership attributes will be defined.<\/p>\n\n\n\n
-v<\/code> \u2013 This is the verbose option. It prints the backup process on the terminal.<\/p>\n\n\n\n–delete <\/code>\u2013 This option enables you to make an incremental backup. In simple terms, with exception of the first backup, it only backs up the difference existing between the source and the destination backup drive. It only backs up new and modified files as well as deletes all the files in the backup location which have been deleted.<\/p>\n\n\n\n–dry-run<\/code> \u2013 This is the option that simulates the backup process.<\/p>\n\n\n\n–exclude<\/code> \u2013 As the name suggests, it excludes specific folders and files from being backed up. The files and folders to be excluded are defined between the double curly braces { }.\u00a0<\/p>\n\n\n\nRun the Actual Backup and Restore Backup to Other PCs<\/h3>\n\n\n\n Once the test run is complete, now run the actual backup command:<\/p>\n\n\n\n
$ sudo rsync -aAXv \/ \u2013-delete –exclude={\/dev\/*,\/proc\/*,\/sys\/*,\/tmp\/*,\/run\/*,\/mnt\/*,\/media\/*,\/cdrom\/*,\/lost+found} \/backup<\/code><\/p>\n\n\n\n <\/figure>\n\n\n\nThe backup process takes quite some time, depending on the data on the directories you are backing up.<\/p>\n\n\n\n