Recent

Author Topic: Backup script for your projects  (Read 4185 times)

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Backup script for your projects
« on: May 11, 2011, 02:06:27 am »
Harddisks can be damaged so it is important to backup projects on different medias - other harddisk, optical discs or flashdisks.
If you are on Linux you can use following shell script.
Code: [Select]
#!/bin/sh

MyProjectsDir='/home/user/Projects'
MyBackupsDir='/home/user/Backups'
MyProject_Dir='Project1'

FullProjectPath=$MyProjectsDir/$MyProject_Dir
if [ ! -x $FullProjectPath ]; then
  if [ ! -x $MyBackupsDir ]; then
    echo Destination directory $MyBackupsDir NOT found.
    exit 0
  fi
  echo Source directory $FullProjectPath NOT found.
  exit 0
fi
Separator='_'
NewBackupDir=$MyProject_Dir$Separator"$(date +%y-%m-%d)"
FullBackupsPath=$MyBackupsDir/$NewBackupDir
if [ -x $FullBackupsPath ]
  then
    echo $FullBackupsPath already exists.
    echo -n 'Type [y], [Y] or [Enter] to continue, other key to exit: '
    read  item   
    if [[ $item != "Y" && $item != "y" && $item != "" ]];
      then exit
    fi
fi
mkdir -p $FullBackupsPath
rsync -av --include='**/'   --include='*.bak' --include='*.bat' --include='*.compiled'  \
  --include='*.ico' --include='*.ini' --include='*.html' --include='*.lfm' \
  --include='*.lpk' --include='*.lpi' --include='*.lpr'  --include='*.lrs' \
  --include='*.or'  --include='*.pas' --include='*.png'  --include='*.pp'  \
  --include='*.rc'  --include='*.res' --include='*.sh'  \
  --exclude='*'  $FullProjectPath/ $FullBackupsPath
If you have directory structure like this:
Code: [Select]
/home/user/Backups
        |-/Projects/Project1
                 |-/Project2
                 |-/Project3
                ...
and if you set script for EACH project properly then each script will create new directory and will backup your project:
Code: [Select]
/home/user/Backups/Project1_11-05-11
                |-/Project2_11-05-11
                |-/Project3_11-05-11
               ...
You need only set user name, source path, destination path and project directory (it is 3-rd, 4-th and 5-th line of the script).
Script backups files in dependency on their extensions and it omits files *.dbg, *.ppu, *.o and executables. Decide yourselves what you want backup and modify script for your own purposes. Generated backups can be also easily burned to CD / DVD with K3B or Brasero.
You can run script manually or you can add it to CRON and it will run automaticly everyday (or in other period). You can configure CRON in GUI - in KDE4 it is in System Settings -> Scheduler.

Bye!

Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

fabienwang

  • Sr. Member
  • ****
  • Posts: 449
  • Lazarus is the best
    • My blog
Re: Backup script for your projects
« Reply #1 on: May 11, 2011, 08:51:20 am »
Thanks Blaazen.
I just had a harddisk problem, but backup folder generated from lazarus saved my life ^^.
Any idea what Windows users could do? Thanks
I'm using Arch Linux.
Known for: CPickSniff, OpenGrabby
Contributed to: LazPaint

mbuckingham

  • Newbie
  • Posts: 6
Re: Backup script for your projects
« Reply #2 on: July 29, 2011, 10:47:23 am »
Thanks Blaazen.
I just had a harddisk problem, but backup folder generated from lazarus saved my life ^^.
Any idea what Windows users could do? Thanks

I use a batch file containing lines like this:-

set ROBO= /e /COPY:DT /FFT /NS /NC /NDL

robocopy c:\work  s:\nas_backup\work %ROBO%
robocopy c:\util s:\nas_backup\util %ROBO%


"robocopy" is a Microsoft utility which I believe is standard with Vista and Windows7. It can be downloaded for previous versions of Windows. More info can be found here http://en.wikipedia.org/wiki/Robocopy

Malcolm Buckingham





avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: Backup script for your projects
« Reply #3 on: August 01, 2011, 09:02:51 am »
Any idea what Windows users could do?
Cobian Backup works fine. The only free backup solution I could find that makes standard 7zip archives.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

ad1mt

  • Full Member
  • ***
  • Posts: 197
    • Mark Taylor's Home Page
Re: Backup script for your projects
« Reply #4 on: August 14, 2022, 07:40:46 pm »
Thanks Blaazen.
I just had a harddisk problem, but backup folder generated from lazarus saved my life ^^.
Any idea what Windows users could do? Thanks
I've been working a Windows GUI front-end to the Robocopy command-line utility.
There is an existing Robocopy GUI front-end which I've used but don't like it for various reasons.
If anyone is interested, you can have a copy for free. Although its reasonably well-tested, it is an early version, and therefore there is a chance of bugs.
Regards, Mark Taylor.

 

TinyPortal © 2005-2018