Skip to content

Instantly share code, notes, and snippets.

@R3M4G
Created November 15, 2021 17:51
Show Gist options
  • Save R3M4G/39500fac48434564b18ba0350dea2914 to your computer and use it in GitHub Desktop.
Save R3M4G/39500fac48434564b18ba0350dea2914 to your computer and use it in GitHub Desktop.
template for my tar backup script
#!/bin/bash
############################
#
# Backup Script
#
############################
# Source
source_files="/dir"
# Destination
dest="/dir"
# Archive details
day=$(date +%A)
hostname=$(hostname -s)
archive_file="$hostname-$day.tgz"
# Print info
echo "Backing up $source_files to $dest"
date
echo
# Backup
tar czf $dest/$archive_file $source_files
# End
echo
echo "Done"
date
# Long listing of files in $dest to check file sizes.
ls -lh $dest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment