Welcome to the Tiny Core Linux Wiki at tinycorelinux.net!

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
wiki:backup_date [2011/05/24 03:05] – [Backup with Date and Time] Guywiki:backup_date [2022/09/21 17:10] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +====== Backup with Date and Time ======
 +
 +Following is a guide on how to save a backup or encrypted backup with the date and time. You need to be using backup or encrypted backup. After a predetermined number of backups are created (the default is 5), each time a new backup is created, the oldest is deleted.
 +
 +The date and time is in the order year, month, day, then hours, minutes and seconds. This keeps the backup files in order.
 +
 +Open a text editor, and paste the following.
 +
 +<code>#!/bin/sh
 +
 +# This saves a copy of backup or encrypted backup with the date and time.
 +
 +PART=$(cat /opt/.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
 +</code>
 +
 +Save this file as backdate.sh in /opt.
 +
 +Open the terminal and type
 +
 +<code>sudo chmod 775 /opt/backdate.sh</code>
 +
 +To create a backup file with the date every time you turn the computer off, add the following to /opt/shutdown.sh.
 +
 +<code>/opt/backdate.sh</code>
 +
 +==== Manual Backup =====
 +
 +Add the following line to /opt/bootlocal.sh
 +
 +<code>sudo cp /opt/backdate.sh /usr/sbin</code>
 +
 +Restart the computer.
 +
 +To run backup, use
 +
 +<code>filetool.sh -b</code>
 +
 +To create a backup file with the date and time, use
 +
 +<code>backdate.sh</code>
 +
 +==== Restore a Previous Backup ====
 +
 +To restore a previous backup, remove mydata.tgz, and rename the backup you want to restore to mydata.tgz.
 +
 +If using encrypted backup, remove mydata.tgz.bfe, and rename the backup you want to restore to mydata.tgz.bfe.
 +
 +Restart the computer for it to be loaded.
 +
  
Print/export
QR Code
QR Code wiki:backup_date (generated for current page)