WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: TC Exit Options  (Read 1488 times)

Offline LinxBe

  • WikiUser
  • *
  • Posts: 2
TC Exit Options
« on: February 24, 2016, 03:42:41 PM »
Hello,

When you shutdown TC, you have 3 Backup Options: None, Backup and Safe.

I understand Backup and None.
But what does "Safe" mean ?
Difference with "Backup" ? When use it ?

TIA.
LinxBe

Offline nitram

  • Hero Member
  • *****
  • Posts: 1052
Re: TC Exit Options
« Reply #1 on: February 24, 2016, 04:38:48 PM »
Regular  backup  just overwrites the existing /tce/mydata.tgz backup file. Choosing  safe backup  copies the existing mydata.tgz to mydatabk.tgz before overwriting mydata.tgz. Useful to have a backup copy in case of data corruption or restore previous settings. Generally the backup files are small so it's wise to perform a safe backup periodically. Open the Control Panel -> Backup/Restore and select Safe (backup) -> Go, you will see "Copying existing backup to */mydatabk.tgz".

Offline nitram

  • Hero Member
  • *****
  • Posts: 1052
Re: TC Exit Options
« Reply #2 on: February 24, 2016, 04:46:31 PM »
Regarding 'when to use it'. Just like any other system backup, before problems occur! When your system is running well and configured to your satisfaction perform a safe backup. This gives you more freedom to experiment, add and configure additional software, etc and still have a fallback restore point.

Offline netnomad

  • Hero Member
  • *****
  • Posts: 1027
Re: TC Exit Options
« Reply #3 on: February 24, 2016, 11:00:33 PM »
hi friends,

in this forum i found a very useful script for storing even more backups in a timeline:

put backdate.sh to the beginning of shutdown.sh

backdate.sh
Code: [Select]
#!/bin/sh

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

USER=`cat /etc/sysconfig/tcuser`
HOME=`eval echo ~$USER`
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
cp $MYDAT.tgz $DATABACK
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

i really glad that i found this script in this forum, share it.
« Last Edit: February 24, 2016, 11:02:55 PM by netnomad »

Offline netnomad

  • Hero Member
  • *****
  • Posts: 1027
Re: TC Exit Options
« Reply #4 on: February 25, 2016, 07:39:32 AM »
hi friends,

it´s even documentated in the wiki :-)

http://wiki.tinycorelinux.net/wiki:backup_date

enjoy it!

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1703
Re: TC Exit Options
« Reply #5 on: February 25, 2016, 08:58:23 AM »
The code posted in the wiki is for earlier versions of Core though.
Code: [Select]
PART=$(cat /opt/.backup_device)
versus
Code: [Select]
PART=$(cat /etc/sysconfig/backup_device)

Hey netnomad,
This seems to be unused?
Code: [Select]
USER=`cat /etc/sysconfig/tcuser`
HOME=`eval echo ~$USER`


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: [Select]
#!/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

Maybe too much but doesn't hurt, right? q:
« Last Edit: February 25, 2016, 09:02:07 AM by Misalf »
Download a copy and keep it handy: Core book ;)