If you don't have an external hard drive, or you simply prefer to store your backups on CD- or DVD-rom, you can create ISO images and burn the image to optical media. This particular script places the temporary .iso file in the Ubuntu /tmp directory, then removes it before the script ends. This ensures that your hard drive will not be clogged up with large .iso files.
#! /bin/bash
#The directory that should be backed up
folder=/home/$USER
#The temporary .iso file (this will be removed)
temp_file=/tmp/backup.iso
mkisofs -o $temp_file $folder
##Uncomment the line that corresponds to the media you want to use
##cdrecord is used for cd-rom
##growisofs is used for dvd-rom
#cdrecord -v -dao dev=2,0,0 $temp_file
#growisofs -dvd-compat -Z /dev/cdrom=$temp_file
#Remove the temporary .iso file.
rm -f $temp_file
This script can be used to backup to either a CD or DVD. To use it with a CD, uncomment the “cdrecord” line. To use it with a DVD line, uncomment the “growisofs” line. The only caveat here is that the backups cannot exceed the size of the removable media. If you have a lot of data that needs to be backed up, you will have to separate the data and create multiple scripts.