Tiny Core Base > CorePlus

TC Exit Options

<< < (2/2)

Misalf:
The code posted in the wiki is for earlier versions of Core though.

--- Code: ---PART=$(cat /opt/.backup_device)

--- End code ---
versus

--- Code: ---PART=$(cat /etc/sysconfig/backup_device)

--- End code ---

Hey netnomad,
This seems to be unused?

--- Code: ---USER=`cat /etc/sysconfig/tcuser`
HOME=`eval echo ~$USER`

--- End code ---


Also, even though I never did it with the tce-dir because it's said to be bad practice on linux in general, but I think some paths and/or file names could contain spaces, thus respective variables should be quoted?

--- Code: ---#!/bin/sh

# This saves a copy of backup or encrypted backup with the date and time.

PART="$(cat /etc/sysconfig/backup_device)"
MYDAT="$(cat /etc/sysconfig/mydata)"
DATE="$(date +"%Y.%m.%d-%H.%M.%S")"
DATABACK="$MYDAT-$DATE.tgz"
CRYPTBACK="$MYDAT-$DATE.tgz.bfe"
cd "/mnt/$PART"
[ -e "$MYDAT.tgz" ] && cp "$MYDAT.tgz" "$DATABACK"
[ -e "$MYDAT.tgz.bfe" ] && cp "$MYDAT.tgz.bfe" "$CRYPTBACK"

# This deletes the oldest if there are more than the number you select (the default is 5).

NUMBACK="$(ls "$MYDAT"-2* | wc -l)"
while [ "$NUMBACK" -gt 5 ]  # Change 5 to the number of backups you want to keep.
do
ls -1t $MYDAT-2*tg* | tail -1 | xargs /bin/rm -f
NUMBACK="$(ls "$MYDAT"-2* | wc -l)"
done


--- End code ---
Maybe too much but doesn't hurt, right? q:

Navigation

[0] Message Index

[*] Previous page

Go to full version