Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

This script uses variables to make a backup of my home directory.

#!/bin/bash
                                                                                                 
# This script makes a backup of my home directory.

# Change the values of the variables to make the script work for you:
BACKUPDIR=/home
BACKUPFILES=franky
TARFILE=/var/tmp/home_franky.tar
BZIPFILE=/var/tmp/home_franky.tar.bz2
SERVER=bordeaux
REMOTEDIR=/opt/backup/franky
LOGFILE=/home/franky/log/home_backup.log

cd $BACKUPDIR

# This creates the archive
tar cf $TARFILE $BACKUPFILES > /dev/null 2>&1
                                                                                                 
# First remove the old bzip2 file.  Redirect errors because this generates some if the archive 
# does not exist.  Then create a new compressed file.
rm $BZIPFILE 2> /dev/null
bzip2 $TARFILE

# Copy the file to another host - we have ssh keys for making this work without intervention.
scp $BZIPFILE $SERVER:$REMOTEDIR > /dev/null 2>&1

# Create a timestamp in a logfile.
date >> $LOGFILE
echo backup succeeded >> $LOGFILE
Comment

PREVIOUS NEXT
Code Example
Shell :: master branch renamed 
Shell :: files still appear as modified after addition to .gitignore 
Shell :: uninstall debian kodi 
Shell :: what is vagrant and system requirements 
Shell :: BertinAm github 
Shell :: how to know branch from which add branch 
Shell :: How do I fix issue "E: some index files fail to download.They have been ignored or old ones are used instead" while apt-get update 
Shell :: How would you make changes to a repository on GitHub inside a bash terminal? 
Shell :: view block devices and file systems on linux 
Shell :: install gnuunicorn pip 
Shell :: ubuntu remove non-breaking spaces from file 
Shell :: check_mk ubuntu 20.04 
Shell :: promtail multiline 
Shell :: length 2 
Shell :: how to extract sequential files multiple zip files at once 
Shell :: c myprintf 
Shell :: command t0 install Squarify in python 
Shell :: kill process in win by pid 
Shell :: kill process running on port 80 
Shell :: docker force new build without cache 
Shell :: install wordpress on xampp 
Shell :: [ERROR] An error occurred while running subprocess capacitor. 
Shell :: how can I use eog command in windows subsystem linux? 
Shell :: renaming a file github 
Shell :: install bottle 
Shell :: ver ayuda de comandos en linux 
Shell :: install a file from internet with command prompt 
Shell :: ligne de commande pour installer lex sur linux 
Shell :: linux get notification if bettery full 
Php :: php cors disable 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =