[Novalug] is this obvious (to everyone but me?)

John Franklin franklin@elfie.org
Sat Apr 4 12:12:04 EDT 2015


I think there is a script out there inspired by Apple's Time Machine that creates daily snapshots without doing a full dump.  In a nutshell, the script does roughly the following:

mkdir `date
cd $source
find . -type d -exec mkdir -p "$target/{}" \;
find $target_previous -type f -exec ln "{}" "$target/{}" \;
rsync -aHv --delete . $target/.

This creates the current directory structure, then creates hard links from the previous backup, then rsyncs the new / changed files over it.

jf

On Apr 4, 2015, at 11:35 AM, pereira <ninorpereira@gmail.com> wrote:

> 
> I want to backup the home directory. For many years I've had the script, below.
> I think it has all the different requirements for something that works; in fact,
> it has mostly comments to myself (which, if you don't mind, I leave for you
> to giggle over if you were so inclined: it might be full of half-digested knowledge).
> 
> Nino
> 
> pereira@p:~$ cat bin/backup
> 
> # /home/pereira/bin/backup
> 
> # Backup script cobbled together by Nino Pereira over the years.
> # An alternative, 'deja-dup', doesn't seem to be reliable.
> 
> # This script describes the various blind alleys I've found,
> # so that I might remember them next time I have to write a script,
> # and includes comments that explain what's happening.
> 
> # Here it goes.
> #!/bin/bash
> #
> # Data on computers that I still have, but no longer run; moreover I don't
> # have fixed IP addresses any more. Instead, I have a hub with IP addresses
> # on a Local Area Network (LAN), viz., 192.168.1.nnn, with 'nnn' a number that
> # is handed out, automatically and in order', by the hub.
> # 66.92.144.240 (lithium, built by Dohn Arms, running debian): turned off
> # 66.92.144.133 (ibm, running Ubuntu *8.04 (Hardy Heron): carries web page
> # the windows-XP machine used to be 66.92.144.90: this IP address is now 'steve'.
> # the dual-core linux machine from Friendly Computers is 66.92.144.89: turned off
> # Right now (01Jan2013) the only machine that is always 'on' is steve, now
> # renamed something else (for no good reason that I can think of).
> # Backup was done earlier on /media/Mybook ...
> # but is now done on the second disk in this machine, /dev/sda1, mounted at /backup.
> 
> # specify the date, and start a new log file
> /bin/date > /home/pereira/zzzzz-backup.log
> 
> # With a fixed IP address, this is a sample command; change the IP address as needed.
> HOST=66.92.144.133
> 
> # You may want to check that the place where you do a backup really exists.
> # How to do that (with if      -e    fi   ?) I don't know and don't want to figure out right now
> # back up to the external disk called 'My Book 3.0':
> # This is problematic because of the spaces in the filename.
> # HOST=/media/"My Book 3.0"/disk/     # doesn't work....
> # HOST=/media/'My\ Book\ 3.0'/disk     # doesn't work either
> # HOST='/media/'My\ Book\ 3.0/disk'     # might have worked but I found another way:
> # make a soft link to the offending file, like this:
> # Go to '/media', and there do (as sudo)
> # ln -s My Book 3.0/disk disk
> # this is possible because you can have the shell expand 'My' to 'My Book 3.0'
> # Now the command HOST=/media/My Book 3.0/disk becomes
> # HOST=/media/disk/
> 
> # if you want the second disc for backup, activate this line instead:
> HOST=/backup/
> 
> # verify that you have the right place: store the info in the existing log file
> /bin/echo 'Start backup to disk:' $HOST >> /home/pereira/zzzzz-backup.log
> 
> # Directory to be backed up: only my own stuff. Anything else
> # can be reconstructed from the source. When you install a new
> # system, back up anything you have configuration files for
> # (like what???)
> 
> LOCALDIR=/home/pereira
> /bin/echo 'directory backed up:' $LOCALDIR >> /home/pereira/zzzzz-backup.log
> # Directory to back up to: create this first on the backup medium.
> # On 'My book' this is REMOTEDIR=home/p-2013-10, with the appendix the date.
> # On the second disk this is /pereira-yyyy-mm
> 
> # Directory everything gets backed up to:
> REMOTEDIR=pereira-2014-01
> 
> # Verify it goes to the right place:
> /bin/echo 'backed up to directory:' $HOST$REMOTEDIR >> /home/pereira/zzzzz-backup.log
> 
> # If all you want to do is to check the names of the files, uncomment this:
> # exit
> 
> #  (Contrary to the documentation, the environment must be
> # given on the command-line of rsync).
> # Set the environment variable RSYNC_RSH
> 
> RSYNC_RSH=ssh
> 
> # Backup $LOCALDIR to $REMOTEDIR on $HOST:
> # use ssh
> # --verbose: show the file names as they are being transferred
> # recursive
> # --archive ??
> # --exclude: exclude the invisible directories (those starting with '.').
> /usr/bin/rsync --rsh=ssh --verbose --recursive --archive --compress --exclude .* $LOCALDIR $HOST$REMOTEDIR
> #
> # It is possible to run other backups, within this script, on
> # subsequent lines.
> 
> # To verify that everything works, write a 'complete' message:
> /bin/echo '--------------- BACKUP DONE -----------------------' > /home/pereira/zzzzz-backup.log
> 
> # end of script
> pereira@p:~$
> 
> On 04/04/2015 11:30 AM, John Franklin wrote:
>> That assumes you have a place to store the backups and the script has a strategy for expiring backups.  For certain tasks, there are packages that do this.  The automysqlbackup package[1], for example, includes the script and by default saves everything to someplace in /var (I forget where exactly).  This script doesn't do incrementals, only full backups. If you were trying to backup your home directory, you'd want something more clever.
>> 
>> What are you trying to backup?
>> 
>> jf
>> [1] https://packages.debian.org/search?keywords=automysqlbackup
>> 
>> On Apr 4, 2015, at 11:24 AM, pereira via Novalug <novalug@firemountain.net> wrote:
>> 
>>> List,
>>> 
>>> is doing a daily backup as simple as putting a backup script in /etc/cron.daily?
>>> Do all the executables in that directory get edited daily?
>>> 
>>> Thank you for any hand-holding you may offer.
>>> 
>>> Nino
>>> **********************************************************************
>>> The Novalug mailing list is hosted by firemountain.net.
>>> 
>>> To unsubscribe or change delivery options:
>>> http://www.firemountain.net/mailman/listinfo/novalug

-- 
John Franklin
franklin@elfie.org






More information about the Novalug mailing list