SAMBA + CWRSYNC

“BACKUP FOLDER FROM SOURCE TO THE DESTINATION WITH TIMESTAMP”

Have you experience doing important files on your computer and lost it for a reason you can’t predict? In my field which I spend great amounts of time on my computer for important things, there’s a possibilities that my computer might crash or it may infect with computer viruses that may results in a loss of documents so it is necessary for me to backup important files or data. That’s why in my stay here at 8LayerTech, my project is to “backup folder from source to the destination with timestamp using Samba and Cwrsync”In this way, you may schedule your backups.

How to backup files using Samba and CWrsync from Windows to Linux?

****************************************************************************
****************************FOR ACCOUNT HOME FOLDER*************************
****************************************************************************

I.”FOR ACCOUNT HOME FOLDER”

  • STEP 1 (How to install Samba in Linux?)

What is Samba?

Samba is a re-implementation of the SMB/CIFS networking protocol, it facilitates file and printer sharing among Linux and Windows systems as an alternative to NFS. It is used to open another computer to access shared files.

https://wiki.archlinux.org/index.php/Samba

1. Open a terminal and install the samba package for sharing files.

$sudo pacman -S samba

2. To log into a Samba share, we need to add password for your user.

# smbpasswd -a <user>

3. Configure your Samba

$ sudo nano /etc/samba/smb.conf

NOTE: It is important that your WORKGROUP in your Samba server is the same as your WORKGROUP in Windows.

Here is my configuration for account homefolder.

[global]
workgroup = YOUR_WORKGROUP
server string = Samba server
Netbios name = YOUR_HOSTNAME
security = user

Example:

[global]
workgroup = WORKGROUP
server string = Samba server
Netbios name = ginalyn
security = user

4. Start running your Samba

$ sudo /etc/rc.d/samba restart

5. Open your Windows, click Start, Run then type your Linux server IP Address followed by your home folder name.

  • STEP 2 ( Network Mapping)

1.  In your Windows, Click My Computer > Tools > Map Network Drive

This Step helps you to connect to a shared network  and assign a drive letter to the connection so that you can access your Linux account using My Computer.

  • STEP 3 ( Install CWRSYNC- client)

Install cwrsync client to your Windows. Cwrsync is available here:  http://prdownloads.sourceforge.net/sereds/cwRsync_1.2.5_Installer.zip?download

What is CWRSYNC?

CWRSYNC is a program run from a batch file, which used for fast remote file backups and synchronization at scheduled time.

  • STEP 4 (SCHEDULER)

After installing cwrsync, make a batch file/script to copy files from Windows to Linux with timestamp. Below is an example;

@ECHO OFF
REM *****************************************************************
REM
REM 8LayerTechnologies
REM 8liens@8layertech.com
REM 8layer technologies, Inc.
REM http://www.8layertech.com
REM *****************************************************************

SETLOCAL
SET CWRSYNCHOME=%PROGRAMFILES%\CWRSYNC
SET HOME=%HOMEDRIVE%%HOMEPATH%
SET CWOLDPATH=%PATH%
SET PATH=%CWRSYNCHOME%\BIN;%PATH%
SET dt=%date:~10,4%%date:~4,2%%date:~7,2%

rsync -r --progress /cygdrive/c/test/ /cygdrive/o/TEST-%dt%

References:
https://wiki.archlinux.org/index.php/Samba
http://devilandvampire.wordpress.com/2008/10/18/rsync/
****************************************************************************
******************************FOR SHARED FOLDER*****************************
****************************************************************************

II.”FOR SHARED FOLDER”

How to backup files using Samba and CWrsync from Windows to Linux?

  • STEP 1 (How to install Samba in Linux?)

https://wiki.archlinux.org/index.php/Samba

1. Open a terminal and install the samba package for sharing files.

$sudo pacman -S samba

2. Make your folder to be shared.

# cd /
# pwd
/
# mkdir foldername
# ls -l

3. Add user for your foldername

$ sudo chown <user> foldername
$ ls -l

4. To log into a Samba share, we need to add password for your user.

# smbpasswd -a <user>

5. Configure your Samba

$ sudo nano /etc/samba/smb.conf

NOTE: It is important that your WORKGROUP in your Samba server is the same as your WORKGROUP in Windows.

Here is my samba configuration for sharedfolder
I just added these lines to my samba configuration.

[sharedfolder]
path = /foldername
available = yes
validusers = <username>
readonly = no
browseable = yes
public = yes
writable = yes
Example:

[sharedfolder]
path = /sharedfolder
available = yes
validusers = ginalyn
readonly = no
browseable = yes
public = yes
writable = yes

6. Start running your Samba

$ sudo /etc/rc.d/samba restart

7. Open your Windows, click Start, Run then type your Linux server IP Address followed by your shared folder name.

  • STEP 2 ( Network Mapping)

1.  In your Windows, Click My Computer > Tools > Map Network Drive

This Step helps you to connect to a shared network folder and assign a drive letter to the connection so that you can access the folder using My Computer.

  • STEP 3 ( Install CWRSYNC- client)

Install cwrsync client to your Windows. Cwrsync is available here:  http://prdownloads.sourceforge.net/sereds/cwRsync_1.2.5_Installer.zip?download

What is CWRSYNC?

CWRSYNC is a program run from a batch file, which used for fast remote file backups and synchronization at scheduled time.

  • STEP 4 (SCHEDULER)

After installing cwrsync, make a batch file/script to copy files from Windows to Linux with timestamp. Below is an example;

@ECHO OFF
REM *****************************************************************
REM
REM 8LayerTechnologies
REM 8liens@8layertech.com
REM 8layer technologies, Inc.
REM http://www.8layertech.com
REM *****************************************************************

SETLOCAL
SET CWRSYNCHOME=%PROGRAMFILES%\CWRSYNC
SET HOME=%HOMEDRIVE%%HOMEPATH%
SET CWOLDPATH=%PATH%
SET PATH=%CWRSYNCHOME%\BIN;%PATH%
SET dt=%date:~10,4%%date:~4,2%%date:~7,2%

rsync -r --progress /cygdrive/c/test/ /cygdrive/j/TEST-%dt%

ENJOY!

References:
https://wiki.archlinux.org/index.php/Samba
http://devilandvampire.wordpress.com/2008/10/18/rsync/
Sir meric (r3d3ye)

Original post by Ginalyn Apostol
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: