Skip to content

Instantly share code, notes, and snippets.

@Drewlius
Last active July 17, 2026 19:45
Show Gist options
  • Select an option

  • Save Drewlius/a1e2c003bb2390adb60c10c2a3f65568 to your computer and use it in GitHub Desktop.

Select an option

Save Drewlius/a1e2c003bb2390adb60c10c2a3f65568 to your computer and use it in GitHub Desktop.
Backup Home Profile

Backup Your Home Directory

So simple you mother could do it

This script expects you to have a secondary storage drive mounted in /mnt (/mnt/<Desired_Location>

This is not a strictly enforced requirement and you may edit the script to suit your needs.

Grant the script the permission to be executed

chmod +x ~/Home/Downloads/<backup-home.sh> (or wherever you saved it)  

Run the script in your preferred terminal via its absolute path

The script will then take you to the /mnt directory

You will the be shown the directories located inside of /mnt

You will be interactively requested to input the name of the directory you want the backup stored in

You will be required to input a "Y" (Case Sensitive) to confirm your designation The copy process will begin and you will be informed when it is completed, be patient and don't close the terminal preemptively.


Features of the script include the ability for it to be ran over and over again as it is set up to only copy over new files or newly accessed, modified files. Therefore the first copy will take the longest, each subsequent backup should take a noticeably less amount of time.

#!/bin/bash
echo "Navigating to your /mnt directory (cd /mnt)";cd /mnt || exit 1;echo "Displaying your mounted directories";dir
read -p "Select the desired backup directory, you must type the full path > /" BACKUP_LOCATION; echo
read -n1 -p "Are you sure you want to create the backup at $BACKUP_LOCATION (Y/n) > " c; echo
case $c in
Y) mkdir -p $BACKUP_LOCATION/Home_Backup;cp --update -n -r /home/$USER /mnt/$BACKUP_LOCATION/Home_Backup;echo "Backup Completed and stored at $BACKUP_LOCATION/Home_Backup";;
n) echo "Y was not chosen, exiting script and handing control back to your shell"; sleep5; wait;exit 1;
esac
#!/bin/bash
echo "Navigating to your /mnt directory (cd /mnt)";cd /mnt || exit 1;echo "Displaying your mounted directories";ls -la
read -p "Input your desired backup top level mount point, you must type the full name of the mnt point > /mnt/" BACKUP_LOCATION; echo
read -n1 -p "Are you sure you want to create the backup at $BACKUP_LOCATION (Y/n) > " c; echo
case $c in
Y) mkdir -p $BACKUP_LOCATION/Home_Backup;rsync -a -r --verbose --ignore-existing $HOME /mnt/$BACKUP_LOCATION/Home_Backup;echo "Backup Completed and stored at $BACKUP_LOCATION/Home_Backup Passing Control Back to Your Shell";sleep 5;exit 0;;
n) echo "Y was not chosen, exiting script and handing control back to your shell"; sleep 5; wait;exit 1;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment