NSLU2-Linux
view · edit · print · history

This shell backup script uses rsync to do "on line" incremental backup of your computers.

Follow instructions at ccollect.sh main web site

I suggest using rsync protocol instead of ssh tunnel as this gives less stress to CPU.

Simple example

On machine that needs to be backed up install rsync and edit rsyncd.conf to allow rsync access from backup server. eg:

[optware]
        path = /opt
        comment = Dodatni paketi
        read only = yes
        hosts allow = 192.168.1.20
        hosts deny = *

Verify access from your backup box with rsync hostname::. Module optware should be listed. Try rsync -tvr hostname::optware /tmp/harddisk/backup if it works.

ccolect backup configuration goes under /opt/etc/ccollect/sources directory. Create backup-name directory there and add source file like:

  192.168.1.20::optware 

and symbolic link named destination to backup directory.

Self backup creation session would be:

 
root@oleo:/home/root# cd /opt/etc/ccollect/sources
root@oleo:/opt/etc/ccollect/sources# mkdir optware
root@oleo:/opt/etc/ccollect/sources# cd optware
root@oleo:/opt/etc/ccollect/sources/optware# echo "192.168.1.20::optware" > source
root@oleo:/opt/etc/ccollect/sources/optware# mkdir /home/backup/optware
root@oleo:/opt/etc/ccollect/sources/optware# ln -s /home/backup/optware destination

and run manually

root@oleo:/opt/etc/ccollect/sources/optware# cd    
root@oleo:/home/root# ccollect.sh weekly optware
Executing /opt/etc/ccollect/defaults/pre_exec ...
#!/bin/cat

If you see this content, pre_exec was executed.
(general pre_exec, not source dependent)
Finished /opt/etc/ccollect/defaults/pre_exec.
==> ccollect 0.5.2: Beginning backup using interval weekly <==
[optware] Wed Jun 27 18:25:58 UTC 2007 Beginning to backup
[optware] Currently 0 backup(s) exist(s), total keeping 4 backup(s).
...
[optware] Backup lasted: 0:10:36 (h:m:s)
Wed Jun 27 18:47:07 UTC 2007 Executing /opt/etc/ccollect/defaults/post_exec ...
#!/bin/cat

######################################################################
If you see this content, post_exec was executed.  (general post_exec)
######################################################################
Wed Jun 27 18:47:07 UTC 2007 Finished /opt/etc/ccollect/defaults/post_exec.
==> Finished  <==

This could be run within crontab -e like

 
0 3 * * 7       /opt/bin/ccollect.sh weekly optware

Backup Windows clients with ccollect

With ccollect it is also possible to backup windows boxes. One needs to install cwRsync server on windows. cwRsync server can be downloaded from sourceforge site.

See cwRsync - Rsync for Windows site for details. I suggest to download only server component. As mentioned before I do not recommend ssh tunnel for rsync backup as this gives additional CPU burden to backup box. When installing cwRsync service, SSH component is thus not needed for backup transport. SSH component can be used for creating ssh tunnel over internet and triggering backup at user logon.

Windows Vista notes

Wista refuses to install cwRsync server package. Create shortcut and modyfy compatibility mode to Windows XP. Then installation goes through.

Afer service installation edit rsyncd.conf and start Rsync server from My Computer->Manage->services

Windows firewall normally blocks access to TCP port 831 where daemon resides. Use control panel -> Security -> Open port to allow access from backup machine.

Unattended backup

ccollect is intended to do unattended backup through cron service. This means than machine should be available at time given in crontab. If this is not the case then one should assure this with "Wake on Lan" powering machine on. For shutting Windows machine down I suggest LeonDown service.

There is also possibility to initiate backup with ssh command from windows machine to backup box. For backuping Windows machines I suggest to create scheduled task on windows machine that will trigger ccollect at backup machine. For sparselly connected computer it is best that scheduled task is triggered at user logon and delayed for an hour or so. Such "pull" initiated backup cannot be regarded as daily and for that I suggest that backup rotation scheme should be created as logon with simple

 $ cd /opt/etc/ccollect/defaults/intervals/
 cp daily logon

to compensate confusion of two or more logons at one day.

Triggering backup at ccollect machine from Windows can be done with ssh component that comes with cwRsync server install. Use ssh-keygen -t rsa for creating logon key and then add id_rsa.pub key to ccollect machine logon account in $HOME/.ssh/authorized_keys. This will enable Windows machine to initiate ccollect task without entering password. Of course one needs to have ipkg install openssh first.

The following listing shows complete XML file for Windows vista that can be imported into task scheduler:

  <?xml version="1.0" encoding="UTF-16" ?> 
- <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
- <RegistrationInfo>
  <Date>2007-06-01T20:43:04.7073633</Date> 
  <Author>lian\silvana</Author> 
  <Description>Na strežniku OLEO je program ccollect, ki skrbi za sinhronizacijo s programom rsync.</Description> 
  </RegistrationInfo>
- <Triggers>
- <LogonTrigger id="c10bac05-8c4b-4224-a730-bed95e489324">
  <ExecutionTimeLimit>PT8H</ExecutionTimeLimit> 
  <Enabled>true</Enabled> 
  <UserId>lian\silvana</UserId> 
  <Delay>PT1H</Delay> 
  </LogonTrigger>
  </Triggers>
- <Principals>
- <Principal id="Author">
  <UserId>lian\silvana</UserId> 
  <LogonType>InteractiveToken</LogonType> 
  <RunLevel>LeastPrivilege</RunLevel> 
  </Principal>
  </Principals>
- <Settings>
- <IdleSettings>
  <Duration>PT10M</Duration> 
  <WaitTimeout>PT1H</WaitTimeout> 
  <StopOnIdleEnd>true</StopOnIdleEnd> 
  <RestartOnIdle>false</RestartOnIdle> 
  </IdleSettings>
  <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy> 
  <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries> 
  <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries> 
  <AllowHardTerminate>true</AllowHardTerminate> 
  <StartWhenAvailable>false</StartWhenAvailable> 
  <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable> 
  <AllowStartOnDemand>true</AllowStartOnDemand> 
  <Enabled>true</Enabled> 
  <Hidden>false</Hidden> 
  <RunOnlyIfIdle>false</RunOnlyIfIdle> 
  <WakeToRun>false</WakeToRun> 
  <ExecutionTimeLimit>P1D</ExecutionTimeLimit> 
  <Priority>7</Priority> 
  </Settings>
- <Actions Context="Author">
- <ShowMessage>
  <Title>Backup se je za&#269;el!</Title> 
  <Body>Rezervna kopija za Silvano, Eudoro in Pictures se sinhronizira s strežnikom OLEO. 
Ne ugašaj ra&#269;unalnika, dokler se ne kon&#269;a sinhronizacija!</Body> 
  </ShowMessage>
- <Exec>
  <Command>"C:\Program Files\cwRsyncServer\bin\ssh.exe"</Command> 
  <Arguments>admin@oleo nice -20 /opt/bin/ccollect.sh logon silvana eudora pictures</Arguments> 
  </Exec>
- <ShowMessage>
  <Title>Backup kon&#269;an</Title> 
  <Body>Sinhronizacija podatkov na OLEO je uspela.</Body> 
  </ShowMessage>
  </Actions>
  </Task>
view · edit · print · history · Last edited by oleo.
Originally by oleo.
Page last modified on February 13, 2008, at 08:02 AM