Hello yes i was wondering if anyone knows any good simple bash scripts for backing up my hard drive onto a external hard drive>?
Printable View
Hello yes i was wondering if anyone knows any good simple bash scripts for backing up my hard drive onto a external hard drive>?
I use this script to back up one of my folders. you can make changes to it to backup the files to the drive in question I hope this helps
###############CODE####################3
#!/bin/bash
## This script uses the tar, mkdir and the cp commands
## to create an archive of files and place the files
## in an archive directory
# Scan System for an archive directory
# if it does not exist, then create the directory
# Bash variable
if [ -e $HOME/backups ]
then
echo "The Backup Directory exists."
else
echo "A Backup directory does not exist, one will be created."
mkdir $HOME/Backup
echo "The backup directory has been created."
fi
# Define variables and the location of the files to be archived
FILES=$HOME/SkunkWorks
# Name of the compressed files
ARCHIVENAME=Code-`date +%F`.tgz
# Location of the archive directory
BACKUPDIR=/home/jraglin/Backup
# Create compressed archive and copy the compressed
# files to the Archive directory and Display a status
tar czf $ARCHIVENAME $FILES
cp -ap $ARCHIVENAME $BACKUPDIR
if [ -e $BACKUPDIR/$ARCHIVENAME ]
then
echo " The files were backup!"
else
echo " The Files were not backup. DEBUG Backup.sh "
fi