Thursday, September 27, 2012

Running Rsync Server as Service on Windows 7 (64 Bit)

What if i want running Rsync server as service on Windows, here :
cygrunsrv -I "RSYNC" -d "Rsync daemon" -p rsync.exe -a "--config=rsyncd.conf --daemon --no-detach" -f "Fast incremental file transfer"
This command will create Rsync daemon service on Windows 7

To start service you can type
cygrunsrv.exe  --start rsync

To stop service you can type
cygrunsrv.exe  --stop rsync


Running Rsync as Daemon on Windows 7 (64 Bit)


After few days strungle with Bash and Rsync on Windows, I decided to combine some tools from main package, because i only need Bash, Rsync and some linux tols to run on Windows 7, and here my experience.

Altought many site said that Rsync only need, this package :
  • Rsync.exe - the executable program
  • cygwin1.dll - the main library file needed by all Cygwin programs
  • cygpopt-0.dll - the library for handling command-line options

In fact, Rsync.exe (Rsync Version 3.0.9) still need one file cygiconv-2.dll, so here's my completed file for running Rsync Version 3.0.9 on Windows 7 (64 Bit).
  • Rsync.exe - the executable program
  • cygwin1.dll - the main library file needed by all Cygwin programs
  • cygpopt-0.dll - the library for handling command-line options
  • cygiconv-2.dll - the library to handling command-line option, also necessary to implement emulator functionality

After all tools complete collected on one folder, i starting create Rsync.conf, a file that contain some neccessary configuration to start Rsync server, and here my Rsync.conf :
use chroot = false
strict modes = false
hosts allow = *
log file = Rsyncd.log
# Module definitions
# Remember cygwin naming conventions : c:\work becomes /cygwin/c/work
[test]
path = /cygdrive/D/
read only = false
transfer logging = yes
after configurating Rsync, it's time to running Rsync server with this simple command
Rsync.exe --config=Rsyncd.conf --daemon --no-detach
that command will bring up Windows DOS Prompt Windows, to stop the Rsync server is simple, just close the Windows Prompt.

To check if your Rsync server running or not, is simple to, from Windows DOS Promt, type the following command :
Rsync.exe localhost::
If you see "test" as output, then your Rsync server is running.

Simple Hah ^^

rsync files

Saturday, September 08, 2012

Part-04 Create Cron Jobs

After creating batch file, this time we would like to run that batch file every time we need it, that why we need Cron.exe from kolab.com. as explain in kolab.com, to setup cron.exe is very simple way, it just take 3 step.

  1. copy the files cron.exe and crontab to a folder of your choice
  2. edit the file crontab (see the examples as a reference)
  3. create a link to cron.exe and move it to the startup folder
Just follow that 3 step and everything would be okay. and here i will copy paste explanation from kolab.com

The Crontab file
Each line of CRONTAB has the following structure:

Position:
Values:
Minute0-59
Hour0-23
Day1-31
Month1-12
Day of week0-6 (0=Sunday, 1=Monday, ..., 6=Saturday)

Instead of minute, hour, day, month or day of week it's also possible to specify a *. A * represents all possible values for that position (e.g. a * on 2nd position is the same as specifying all the possible values for hour)

It's also possible to specify several values separated by commas: e.g. if you want a command to be executed every 10th minute so you can specify 0,10,20,30,40,50 for minute. A range of values can be specified with a -: e.g. value 0-12 for hour -> every hour a.m.
Comments

Every line not starting with a number is treated as a comment.

Examples
execute a command every minute
# This is a comment.
* * * * * c:\tools\CheckForNewFiles.exe

execute the program backup.bat every hour
# This is a comment.
0 * * * * c:\tests\backup.bat

do a backup every day at 0.30 p.m.
# This is a comment. 30 12* * * c:\tests\backup.bat

start a backup every tuesday at midnight
# This is a comment.0 0 * * 3 c:\tests\backup.bat

scan drive c for viruses on the 1st of every month at 2.45 p.m.
# scan for known viruses45 14 1 * * c:\path_to_scanner\scan c:

copy some files every half hour 
# This is a comment.0,30 * * * * xcopy c:\docs\*.* y:\users /s

copy a file every hour (a.m.) only on weekdays
# System commands need the command interpreter specified:0 0-12 * * 1-5 c:\...\cmd.exe /c "copy c:\... e:\"


for another great information for crontab scheduling is wikipedia

Part-03 Creating Batch File

Part-03 Creating Batch File

Oke, after downloading all aplication and create some backup profile, this time we would like to create batch file, so every backup profile that already created will be running  in sequence. and here's the bacth file i created for my backup profile, change as needed.

@echo off
start/wait D:\ProgramsApps\Deltacopy\DeltaC.exe 002009.dcp
start/wait D:\ProgramsApps\Deltacopy\DeltaC.exe 002010.dcp
start/wait D:\ProgramsApps\Deltacopy\DeltaC.exe 002011.dcp
start/wait D:\ProgramsApps\Deltacopy\DeltaC.exe 002012.dcp
start/wait D:\ProgramsApps\Deltacopy\DeltaC.exe 002013.dcp

and save it with name DeltaC.bat

Explenation :

start/wait Start application and wait for it to terminate
D:\ProgramsApps\Deltacopy\DeltaC.exe is my aplication location/path, change as needed
002009.dcp and another *.dcp file is file that holding backup profile name

In simple way start/wait D:\ProgramsApps\Deltacopy\DeltaC.exe 002009.dcp , it's command windows to run DeltaC.exe from it location and running 002009.dcp backup profile.

Part-02 Create Backup Profile

After downloading all aplication, it's time to me to create backup profile using deltacopy (DeltaC.exe), double click DeltaC.exe and create backup profile as you need:

Step-01 : Create backup profile, Just give profile name as you like, in host name field insert with your rsync server name or ip, and for directory name insert with backup location (diretory) on your rsync server. Don't check Assign to scheduler because we would like to use Cron.exe as Task Scheduler.


Step-02 : File list, replace it with the file that you want to backup


Step-03 : for file option, i don't change anything except additional parameters, in this field i put : --exclude='Thumbs.db' --exclude='.DS_Store' --exclude='._*' --exclude='Desktop.ini' --exclude='*.lnk'



Step-04 : In authentication, put username and password that you allow to connect to your rsync server, this configuration is done on server side.


Step-05 : This is only optional choice, do it only if you want notified by email for every backup profile you created, in this example i use my local email server.


make sure you click on Test Email button to test your email notification, if you got display like bellow, it means your setting is correct, if not...than find it by your self :D

Part-01 Create Backup from Windows To Linux Via Rsync and Cron

After a months searching and researching to create simple and clean backup strategy, i found cool and simple solution  for backing up from windows 7 (64 bit) to Linux server running Rsync server, and here's my backup startegy.

Why i would like to use portable application? Because windows every aplication you installed on your windows system will leave a lot of registry junks. that why i choose deltacopy (unzip mode0 and another one. which is free and gpl. as the website said :

In general terms, DeltaCopy is an open source, fast incremental backup program. Let's say you have to backup one file that is 500 MB every night. A normal file copy would copy the entire file even if a few bytes have changed. DeltaCopy, on the other hand, would only copy the part of file that has actually been modified. This reduces the data transfer to just a small fraction of 500 MB saving time and network bandwidth.

And here's the download links

I used only client software because i don't want to running backup server on windows.

and to schedule the rsync backup, i would like to use Cron.exe from kalab.com (mirror), once again, i don't want use windows task scheduler, it's suck program that only running on administrator mode ( not user mode) that way  i use Cron.exe, clean and simple, and the finnest part is, the contab configuration file is compatible with linux crontab. as the web site said :

Cron scans the file CRONTAB every minute and checks every line if the specified time/date information matches the current time/date. If they are equal, the command line specified will be executed. A log file (cron.log) with the executed commands is written to the current directory.

After combining all of that aplication, i got this usefull aplication.

And how i do automatic backup using windows batch? see you on Part-02

Part-02 Create Backup Profile