sinisterporpoise: (Default)
 You can use crontab -e to run the script that come below this. Just add this line to it:

00  0  *  *   *   /home/<yourhomedir>/Downloads/backup.sh  
# This assumes you have left the file in your Downloads folder instead of moving it to a more appropriate place.
# The hashtag is just  makes a line a comment in Linux/Unix scripts. (Mac OS X is Unix.)


Now, exit out of Crontab. On my Linux systems, Crontab uses nano, but many other Linux/Unix distributions use vi/vim.

Here is the script if you want to copy and paste it and put it itno a more convenient directory:

!/bin/bash
 
 
cat << EOF
-----------------------------------------------------------------------------
 
Sinister Porpoise Computing Backup Script
Test script for creating multiple
backup files.
 
Lara Landis
11/10/2017
Personal Bash Script
 
----------------------------------------------------------------------------
EOF
 
echo "Now creating backup files..."
 
x=1
y=1 
 
if [[ -f "backup.tar.gz" ]]; then
    x=1
    while [ x==1 ]
    do
    if [[ -f "backup${y}.tar.gz" ]]; then
y=$((y+1))
echo  $y
else
tar -czvf --exclude=*.tar.gz "backup${y}.tar.gz" /home
x=0
fi
   done
else
tar -cvzf --exclude=*.tar.gz "backup.tar.gz" /home
fi
 
How does this differ from the previous versions?  As written, it will only back up the home directories. For entire hard drive backups, simply switch it to the /home line to / .  First, it creates multiple incremental backups.  Second, unlike the previous versions, it excludes files that have been compressed into a tarball, as long as they have the .tar.gz extensions.  Is this better than Time Machine for Mac users? No, probably not. However, it is a handy backup for it.

sinisterporpoise: (Default)
This works on Linux, Unix and Mac OS X orlater, which I just checkeddoes have cron and the /etc/cronta file. It will create incremental backups.  For Mac users, this can be a way to add additional backups to Time Machine.

To schedule it regularly, you add the favorite line to the /etc/crontab file.   (I use Nano in Linux.)

02     00    *         *        *   /<path to dir>/bakup.sh

To make the script executable run the following commaind

chmod +x backup.sh


Now for the script:

#!/bin/bash
 
 
cat << here
 
-----------------------------------------------------------------------------
 
Sinister Porpoise Computing Backup Script
Test script for creating multiple
backup files.
 
Lara Landis
11/10/2017
Personal Bash Script
 
----------------------------------------------------------------------------
here
 
echo "Now creating backup files..."
 
x=1
y=1 
 
if -e [[ "backup.tar.gz" ]]; then
    x=1
    while (x=1)
    do
if -e [[ "backup" +y +".tar.gz" ]]; then
    x=1
    y=y+1
else 
  tar -czvf "backup" + y + ".tar.gz" /home
  x=0
fi
    done
else 
tar -cvzf "backuptar.gz" /home
fi;


There you go. It's just a simple script. 

Profile

sinisterporpoise: (Default)
sinisterporpoise

April 2019

S M T W T F S
 1234 56
78910111213
14151617181920
21222324252627
282930    

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 8th, 2025 04:28 pm
Powered by Dreamwidth Studios