Skip to content

Instantly share code, notes, and snippets.

@cjerrington
Created March 31, 2022 03:26
Show Gist options
  • Save cjerrington/443beaaec54a99bf4bb767d1209d147a to your computer and use it in GitHub Desktop.
Save cjerrington/443beaaec54a99bf4bb767d1209d147a to your computer and use it in GitHub Desktop.
Simple Bash Backup
#!/bin/bash
####################################
#
# Backup to NFS mount script.
#
####################################
# What to backup.
backup_files="/home/username/Desktop"
# Where to backup to.
dest="/mount/drive/backup/path"
# Create archive filename.
day=$(date +%A)
hostname=$(hostname -s)
archive_file="$hostname-$day.tgz"
# Print start status message.
echo "Backing up $backup_files to $dest/$archive_file"
date
echo
# Backup the files using tar.
tar czf $dest/$archive_file $backup_files
# Print end status message.
echo
echo "Backup finished"
date
# Long listing of files in $dest to check file sizes.
ls -sh $dest/$archive_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment