Created
March 31, 2022 03:26
-
-
Save cjerrington/443beaaec54a99bf4bb767d1209d147a to your computer and use it in GitHub Desktop.
Simple Bash Backup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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