Skip to content

Instantly share code, notes, and snippets.

@dutchmichael
Created November 25, 2016 04:58
Show Gist options
  • Save dutchmichael/c55cd627d70d33fef4cdaa860aaae5fb to your computer and use it in GitHub Desktop.
Save dutchmichael/c55cd627d70d33fef4cdaa860aaae5fb to your computer and use it in GitHub Desktop.
#!/bin/sh
#########################################################
# Backup to NFS mount script.
# https://www.webhostingtalk.com/showthread.php?t=1130207
# It creates 1 compressed .tar file locally you can then
# download over SSH or FTP to your PC. For reference,
# I have a Ubuntu 11.04 OpenVZ VPS and it created a 470MB
# .tar file out of ~600MB. You can specify only certain
# directories for backup by changing backup_files,
# or leaving it to "/" will backup everything.
#########################################################
# What to backup.
backup_files="/"
# Where to backup to.
dest="/home/backup"
# 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 -lh $dest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment