Differences
This shows you the differences between the selected revision and the current version of the page.
howto:backup_-_pc 2008/07/01 15:34 | howto:backup_-_pc 2017/09/06 18:38 current | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | {{howto:page_under_constrct.gif|}} | ||
- | |||
====== DNS323 RSync Time Machine for Windows ====== | ====== DNS323 RSync Time Machine for Windows ====== | ||
- | An interesting article titled "DNS323 RSync Time Machine!" was posted [[http://forum.dsmg600.info/t2125-DNS-323-Rsync-Time-Machine%21.html|here]] on the DNS323 forum. The author, raid123, brought to light some very interesting information regarding use of RSync's hard links. Following implementation of such on my NAS I couldn't help but wonder if a similar approach could be used to backup data from three Windows based PC's located throughout the household. Following a brief search of the Internet I was pleased to see tools capable of assisting in this regard were available. | + | An interesting article titled "DNS323 RSync Time Machine!" was posted [[http://dns323.kood.org/forum/t2125-DNS-323-Rsync-Time-Machine%21.html|here]] on the DNS323 forum. The author, raid123, brought to light some very interesting information regarding use of RSync's hard links. Following implementation of such on my NAS I couldn't help but wonder if a similar approach could be used to backup data from three Windows based PC's located throughout the household. Following a brief search of the Internet I was pleased to see tools capable of assisting in this regard were available. |
\\ | \\ | ||
+ | |||
===== Assumptions ===== | ===== Assumptions ===== | ||
Before getting started lets declare a few assumptions; | Before getting started lets declare a few assumptions; | ||
Line 10: | Line 9: | ||
- Volume_1 of the DNS323 contains user data | - Volume_1 of the DNS323 contains user data | ||
- Volume_2 of the DNS323 contains backup data | - Volume_2 of the DNS323 contains backup data | ||
- | - Your capable of adding folders to the DNS323 and setting user access rights | + | - You are capable of adding folders to the DNS323 and setting user access rights |
- ffp version 0.5 is installed, configured and running without error. Check the fun_plug.log to be sure! | - ffp version 0.5 is installed, configured and running without error. Check the fun_plug.log to be sure! | ||
- You have telnet or SSH access to the /ffp/* folders on your DNS323 | - You have telnet or SSH access to the /ffp/* folders on your DNS323 | ||
- You know how to use | - You know how to use | ||
* and have an editor capable of creating text files on your DNS323 (I use notepad++) | * and have an editor capable of creating text files on your DNS323 (I use notepad++) | ||
- | * the CHMOD command to change files rights | + | * the chmod command to change files rights |
* and create DOS batch files | * and create DOS batch files | ||
* and add a task to the Windows Task Scheduler | * and add a task to the Windows Task Scheduler | ||
Line 21: | Line 20: | ||
\\ | \\ | ||
+ | |||
===== Basics Steps ===== | ===== Basics Steps ===== | ||
Establishing a DNS323 RSync Time Machine for Windows requires; | Establishing a DNS323 RSync Time Machine for Windows requires; | ||
Line 38: | Line 38: | ||
==== Add Storage Folders to Your DNS323 ==== | ==== Add Storage Folders to Your DNS323 ==== | ||
Volume_2 of my DNS323 contains backup data thus three folders were created on this volume to house data copied from each of the three Windows PC. For this example the folders will be named Backup_PC1, Backup_PC2 and Backup_PC3. The folders were created using D-Link's GUI interface. Each folder was assigned access as follows; | Volume_2 of my DNS323 contains backup data thus three folders were created on this volume to house data copied from each of the three Windows PC. For this example the folders will be named Backup_PC1, Backup_PC2 and Backup_PC3. The folders were created using D-Link's GUI interface. Each folder was assigned access as follows; | ||
+ | \\ | ||
+ | \\ | ||
^ Folder Name ^ User Assignment ^ Group ^ Rights ^ | ^ Folder Name ^ User Assignment ^ Group ^ Rights ^ | ||
| Backup_PC1 | User1 | users | R/W | | | Backup_PC1 | User1 | users | R/W | | ||
| Backup_PC2 | User1, User2 | users | R/W | | | Backup_PC2 | User1, User2 | users | R/W | | ||
| Backup_PC3 | User1 | users | R/W | | | Backup_PC3 | User1 | users | R/W | | ||
- | |||
- | Information in the table demonstrates User1 has access to all three folders while User2 has access to only the folder named Backup_PC2. | ||
\\ | \\ | ||
+ | Information in the table shows that User1 has access to all three folders while User2 has access to only the folder named Backup_PC2. | ||
+ | \\ | ||
+ | |||
+ | |||
==== Add Cygwin and RSync for Windows ==== | ==== Add Cygwin and RSync for Windows ==== | ||
- | Installation of a package known as Cygwin on all three Windows PC's is necessary. Cygwin provides an RSync client and allows creation of a symbolic link at the end of the backup process. As with raid123's approach for the "DNS323 RSync Time Machine!", a symbolic link named Current will take you to the latest backup directory. | + | Installation of a package known as Cygwin on all three Windows PC's is necessary. Cygwin provides an RSync client and allows creation of a symbolic link at the end of the backup process. As with raid123's approach for the "DNS323 RSync Time Machine!", a symbolic link named Current will take you to the latest backup directory. |
\\ | \\ | ||
\\ | \\ | ||
- | Following instruction found at [[http://www.gaztronics.net/rsync.php|Gaztronics.net]], install "RSync for Windows". Although the instruction indicates three key Cygwin modules are required, I found that by installing the Cygwin utilities module (cygutils-1.3.2-1) symlinks could be built thus allowing creation of a link to the latest backup. | + | Following instruction found at [[http://www.gaztronics.net/rsync.php|Gaztronics.net]], install "RSync for Windows". Although the instruction indicates three key Cygwin modules are required, I found that by installing the Cygwin GNU core utilities module (coreutils/coreutils-6.10-1) symlinks could be built thus allowing creation of a link to the latest backup. |
\\ | \\ | ||
+ | \\ | ||
+ | There are transfer speed issues between the rsync 3.0.4 versions when using protocol 30. If encountered low transfer speeds (100KB/sec) downgrade the Cygwin rsync package to 2.6.9 to use protocol version 29. | ||
+ | |||
==== Create rsyncd.conf File ==== | ==== Create rsyncd.conf File ==== | ||
Using a text editor that supports Unix line endings create an rsyncd.conf file in the /ffp/etc folder of the DNS323. Save the following information within the file; | Using a text editor that supports Unix line endings create an rsyncd.conf file in the /ffp/etc folder of the DNS323. Save the following information within the file; | ||
- | <code> | + | <code linux> |
# /ffp/etc/rsyncd.conf configuration file | # /ffp/etc/rsyncd.conf configuration file | ||
max connections = 2 | max connections = 2 | ||
secrets file = /ffp/etc/rsyncd.secrets | secrets file = /ffp/etc/rsyncd.secrets | ||
- | + | ||
use chroot = false | use chroot = false | ||
read only = yes | read only = yes | ||
Line 65: | Line 71: | ||
strict modes = false | strict modes = false | ||
# Deny access to all hosts just to be on the safe side | # Deny access to all hosts just to be on the safe side | ||
- | hosts deny = * | + | hosts deny = * |
timeout = 600 | timeout = 600 | ||
dont compress = *.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz | dont compress = *.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz | ||
Line 71: | Line 77: | ||
[PC1Backup] | [PC1Backup] | ||
- | comment = Primary Backup Location for PC1 | + | comment = Primary Backup Location for PC1 |
- | # Allow access to local hosts | + | # Allow access to local hosts |
- | hosts allow = 192.168.1.0/24 | + | hosts allow = 192.168.1.0/24 |
- | read only = false | + | read only = false |
- | gid = users | + | gid = users |
- | uid = User1 | + | uid = User1 |
- | auth users = User1 | + | auth users = User1 |
- | path = /mnt/HD_b2/Backup_PC1 | + | path = /mnt/HD_b2/Backup_PC1 |
[PC2Backup] | [PC2Backup] | ||
- | comment = Primary Backup Location for PC2 | + | comment = Primary Backup Location for PC2 |
- | # Allow access to local hosts | + | # Allow access to local hosts |
- | hosts allow = 192.168.1.0/24 | + | hosts allow = 192.168.1.0/24 |
- | read only = false | + | read only = false |
- | gid = users | + | gid = users |
- | uid = User1 | + | uid = User1 |
- | auth users = User1, User2 | + | auth users = User1, User2 |
- | path = /mnt/HD_b2/Backup_PC2 | + | path = /mnt/HD_b2/Backup_PC2 |
[PC3Backup] | [PC3Backup] | ||
- | comment = Primary Backup location for PC3 | + | comment = Primary Backup location for PC3 |
- | # Allow access to local hosts | + | # Allow access to local hosts |
- | hosts allow = 192.168.1.0/24 | + | hosts allow = 192.168.1.0/24 |
- | read only = false | + | read only = false |
- | gid = users | + | gid = users |
- | uid = User1 | + | uid = User1 |
- | auth users = User1 | + | auth users = User1 |
- | path = /mnt/HD_b2/Backup_PC3 | + | path = /mnt/HD_b2/Backup_PC3 |
</code> | </code> | ||
- | To ensure some level of confidentiality use CHMOD to set the properities of the file to rw-r--r-- (CHMOD 644 /ffp/etc/rsyncd.conf) | + | To ensure some level of confidentiality use chmod to set the proporties of the file to rw-r--r-- (chmod 644 /ffp/etc/rsyncd.conf) |
\\ | \\ | ||
==== Create rsyncd.secrets File on the DNS323 ==== | ==== Create rsyncd.secrets File on the DNS323 ==== | ||
Using a text editor that supports Unix line endings create an rsyncd.secrets file in the /ffp/etc folder of the DNS323. Save the following information within the file; | Using a text editor that supports Unix line endings create an rsyncd.secrets file in the /ffp/etc folder of the DNS323. Save the following information within the file; | ||
- | <code> | + | <code linux> |
# /ffp/etc/rsyncd.secrets configuration file | # /ffp/etc/rsyncd.secrets configuration file | ||
# File context; | # File context; | ||
Line 116: | Line 122: | ||
</code> | </code> | ||
- | To ensure some level of confidentiality use CHMOD to set the properities of the file to rw------- (CHMOD 600 /ffp/etc/rsyncd.secrets) | + | To ensure some level of confidentiality use chmod to set the proporties of the file to rw------- (chmod 600 /ffp/etc/rsyncd.secrets) |
\\ | \\ | ||
==== Create secret File on Each Windows PC ==== | ==== Create secret File on Each Windows PC ==== | ||
Using a text editor that supports Unix line endings create a file named secret in the C:\cygwin\etc folder of each of the three PC's. Only the users password is required within the file. For example the file for User1 would contain the following; | Using a text editor that supports Unix line endings create a file named secret in the C:\cygwin\etc folder of each of the three PC's. Only the users password is required within the file. For example the file for User1 would contain the following; | ||
- | <code> | + | <code linux> |
uh$Y49)f | uh$Y49)f | ||
</code> | </code> | ||
Line 127: | Line 133: | ||
The file for User2 would contain the following; | The file for User2 would contain the following; | ||
- | <code> | + | <code linux> |
gYj$8gI4 | gYj$8gI4 | ||
</code> | </code> | ||
\\ | \\ | ||
- | ==== Start the RSync Deamon ==== | + | ==== Start the RSync Daemon ==== |
- | In order for the RSync client on each PC to communicate with the DNS323, an RSync deamon needs to be running on the DNS323. Using Telenet or Putty access the DNS323 and set the execution bit of the rsyncd.sh file; chmod a+x /ffp/start/rsyncd.sh. Start the deamon by issueing an "/ffp/start/rsyncd.sh start" command. If all is well with your rsyncd.conf file the script should start with an indication of success. | + | In order for the RSync client on each PC to communicate with the DNS323, an RSync daemon needs to be running on the DNS323. Using Telnet or Putty access the DNS323 and set the execution bit of the rsyncd.sh file; chmod a+x /ffp/start/rsyncd.sh. Start the daemon by issuing an "/ffp/start/rsyncd.sh start" command. If all is well with your rsyncd.conf file the script should start with an indication of success. |
\\ | \\ | ||
+ | |||
+ | |||
+ | |||
==== Create DOS Batch File ==== | ==== Create DOS Batch File ==== | ||
Much of the success of this process lies with the DOS batch file and the Windows Task Scheduler. Although I'm running Windows Vista I run a few batch files on a regular basis. As a result I've created a directory in my Documents folder named Batch_Files. All batch files are stored there. To ensure you're able to find your batch file at a later date you may wish to consider doing something similar. | Much of the success of this process lies with the DOS batch file and the Windows Task Scheduler. Although I'm running Windows Vista I run a few batch files on a regular basis. As a result I've created a directory in my Documents folder named Batch_Files. All batch files are stored there. To ensure you're able to find your batch file at a later date you may wish to consider doing something similar. | ||
- | Using your favourite text editor create a batch file named Backup.bat. Copy the contents of the [b]Code:[/b] window to the text editor and save the file to the location of your choice. | + | Using your favourite text editor create a batch file named Backup.bat. Copy the following code into the text editor and save the file to the location of your choice. |
- | <code> | + | <code dos> |
@ echo off | @ echo off | ||
Rem Keep Things Tidy; establish local variables | Rem Keep Things Tidy; establish local variables | ||
setlocal | setlocal | ||
+ | |||
+ | Rem Establish name or IP Addr of DNS323 | ||
+ | set DNS323Name=NameOf_DNS323 | ||
+ | |||
+ | Rem Establish name of Backup folder on DNS323 | ||
+ | set BackUpFolder=Backup_PC1 | ||
+ | |||
+ | Rem Establish RSync User Name | ||
+ | set UserName=User1 | ||
+ | |||
+ | Rem Establish RSync Name | ||
+ | set RSyncModuleName=PC1Backup | ||
+ | |||
+ | Rem Set Source Path | ||
+ | Rem Back up a single directory or drive by identifying the source path as /cygdrive/c or /cygdrive/c/Users/UserName/Documents | ||
+ | Rem The path = /cygdrive/c/Users/UserName/Documents looks a little odd. This is Cygwin convention for defining Windows paths from within a *nix emulator | ||
+ | set srcpath='/cygdrive/C/Documents and Settings/%UserName%/My Documents' | ||
+ | |||
+ | Rem Back up multiple directories by surrounding a list with single quotes (i.e., srcpath='/cygdrive/c/Users/UserName/Documents /cygdrive/c/Users/UserName/Contacts') | ||
+ | Rem set srcpath='/cygdrive/c/Users/UserName/Contacts /cygdrive/c/Users/UserName/Documents /cygdrive/c/Users/UserName/Favorites /cygdrive/c/Users/UserName/Pictures /cygdrive/c/Users/UserName/Videos /cygdrive/c/Users/UserName/Wav' | ||
+ | |||
+ | Rem <------------------------------------------------------------------------------------------> | ||
+ | Rem | ||
+ | Rem No User Configuration Required Beyond This Point! | ||
+ | Rem | ||
+ | Rem <------------------------------------------------------------------------------------------> | ||
Rem Establish DOS backup file path | Rem Establish DOS backup file path | ||
- | set DOSBackUpPath=\\Name_Of_DNS323\Backup_PC1 | + | set DOSBackUpPath=\\%DNS323Name%\%BackUpFolder% |
Rem Establish Cygwin backup file path | Rem Establish Cygwin backup file path | ||
- | set CygwinBackUpPath=//Name_Of_DNS323/Backup_PC1 | + | set CygwinBackUpPath=//%DNS323Name%/%BackUpFolder% |
Rem Using todays date establish name of backup directory | Rem Using todays date establish name of backup directory | ||
Line 158: | Line 193: | ||
REM Obtain date of last backup | REM Obtain date of last backup | ||
Rem NOTE: The usebackq attribute is required; it specifies that the new semantics are in force, where a back quoted string is executed | Rem NOTE: The usebackq attribute is required; it specifies that the new semantics are in force, where a back quoted string is executed | ||
- | Rem as a command and a single quoted string is a literal string command and allows the use of double quotes to quote file names in filenameset. | + | Rem as a command and a single quoted string is a literal string command and allows the use of double quotes to quote file names in filenameset. |
- | for /F "usebackq tokens=*" %%i in ("//Name_Of_DNS323/Backup_PC1/LastBkpDate.dat") do set LastBkpDir=%%i | + | for /F "usebackq tokens=*" %%i in ("%CygwinBackUpPath%/LastBkpDate.dat") do set LastBkpDir=%%i |
- | + | ||
- | Rem Set Source Path | + | |
- | Rem Back up a single directory or drive by identifying the source path as /cygdrive/c or /cygdrive/c/Users/WindowsUserID/Documents | + | |
- | Rem The path = /cygdrive/c/Users/WindowsUserID/Documents looks a little odd. This is Cygwin convention for defining Windows paths from within a *nix emulator | + | |
- | Rem set srcpath=/cygdrive/C/Users/WindowsUserID/Documents | + | |
- | + | ||
- | Rem Back up multiple directories by surrounding a list with single quotes (i.e., srcpath='/cygdrive/c/Users/WindowsUserID/Documents /cygdrive/c/Users/WindowsUserID/Contacts') | + | |
- | set srcpath=/cygdrive/c/Users/WindowsUserID/Contacts /cygdrive/c/Users/WindowsUserID/Documents /cygdrive/c/Users/WindowsUserID/Favorites /cygdrive/c/Users/WindowsUserID/Pictures /cygdrive/c/Users/WindowsUserID/Videos /cygdrive/c/Users/WindowsUserID/Wav | + | |
Rem Establish rsync module name | Rem Establish rsync module name | ||
- | set modulename=User1@Name_Of_DNS323::PC1Backup/%BkpDir% | + | set modulename=%UserName%@%DNS323Name%::%RSyncModuleName%/%BkpDir% |
Rem Perform rsync backup | Rem Perform rsync backup | ||
Line 177: | Line 204: | ||
Rem Save name of current backup directory; information is required next time batchfile runs | Rem Save name of current backup directory; information is required next time batchfile runs | ||
echo %BkpDir% > %DOSBackUpPath%\LastBkpDate.dat | echo %BkpDir% > %DOSBackUpPath%\LastBkpDate.dat | ||
+ | |||
Rem Delete shortcut to Previous Backup Directory | Rem Delete shortcut to Previous Backup Directory | ||
- | if exist %DOSBackUpPath%\Current.lnk del %DOSBackUpPath%\Current.lnk | + | if exist %DOSBackUpPath%\Current.lnk C:\cygwin\bin\rm %CygwinBackUpPath%/current.lnk |
Rem Change drive/directory and create shortcut to Current Backup Directory | Rem Change drive/directory and create shortcut to Current Backup Directory | ||
Line 185: | Line 213: | ||
Rem Clean up variables then exit | Rem Clean up variables then exit | ||
+ | set DNS323Name= | ||
+ | set BackUpFolder= | ||
+ | set UserName= | ||
+ | set RSyncModuleName= | ||
set DOSBackUpPath= | set DOSBackUpPath= | ||
set CygwinBackUpPath= | set CygwinBackUpPath= | ||
Line 198: | Line 230: | ||
=== Tweak The Batch File To your Needs === | === Tweak The Batch File To your Needs === | ||
- | There's a few line of code within the batch file that need to be changed to meet your specific needs. Starting from the top of the batch file you'll want to review and change the following information; | + | There's a few lines of code at the start of the batch file that will need to be changed in order to meet your specific environment. Starting from the top of the batch file you'll want to review and change the following; |
- | == DNS323 Name (Name_Of_DNS323) == | + | == DNS323 Name == |
- | * <code> | + | * <code dos> |
- | Rem Establish DOS backup file path | + | Rem Establish name or IP Addr of DNS323 |
- | --> set DOSBackUpPath=\\Name_Of_DNS323\Backup_PC1 | + | set DNS323Name=NameOf_DNS323 |
+ | </code> | ||
- | Rem Establish Cygwin backup file path | + | == DNS323 Backup Folder name == |
- | --> set CygwinBackUpPath=//Name_Of_DNS323/Backup_PC1 | + | |
- | REM Obtain date of last backup | + | * <code dos> |
- | Rem NOTE: The usebackq attribute is required; it specifies that the new semantics are in force, where a back quoted string is executed | + | Rem Establish name of Backup folder on DNS323 |
- | Rem as a command and a single quoted string is a literal string command and allows the use of double quotes to quote file names in filenameset. | + | set BackUpFolder=Backup_PC1 |
- | --> for /F "usebackq tokens=*" %%i in ("//Name_Of_DNS323/Backup_PC1/LastBkpDate.dat") do set LastBkpDir=%%i | + | </code> |
- | Rem Establish rsync module name | + | == RSync User Name == |
- | --> set modulename=User1@Name_Of_DNS323::PC1Backup/%BkpDir% | + | |
+ | * <code dos> | ||
+ | Rem Establish RSync User Name | ||
+ | set UserName=User1 | ||
</code> | </code> | ||
- | == The Windows PC file source path == | + | == RSync Module Name == |
- | <code> | + | * <code dos> |
- | Rem Set Source Path | + | Rem Establish RSync Module Name |
- | Rem Back up a single directory or drive by identifying the source path as /cygdrive/c or /cygdrive/c/Users/WindowsUserID/Documents | + | set RSyncModuleName=PC1Backup |
- | Rem The path = /cygdrive/c/Users/WindowsUserID/Documents looks a little odd. This is Cygwin convention for defining Windows paths from within a *nix emulator | + | </code> |
- | --> Rem set srcpath=/cygdrive/C/Users/WindowsUserID/Documents | + | |
+ | == The Windows PC Source Path == | ||
+ | |||
+ | * <code dos> | ||
+ | Rem Set Source Path | ||
+ | Rem Back up a single directory or drive by identifying the source path as /cygdrive/c or /cygdrive/c/Users/UserName/Documents | ||
+ | Rem The path = /cygdrive/c/Users/UserName/Documents looks a little odd. This is Cygwin convention for defining Windows paths from within a *nix emulator | ||
+ | set srcpath='/cygdrive/C/Documents and Settings/%UserName%/My Documents' | ||
</code> | </code> | ||
or; | or; | ||
- | <code> | + | * <code dos> |
- | Rem Back up multiple directories by surrounding a list with single quotes (i.e., srcpath='/cygdrive/c/Users/WindowsUserID/Documents /cygdrive/c/Users/WindowsUserID/Contacts') | + | Rem Back up multiple directories by surrounding a list with single quotes (i.e., srcpath='/cygdrive/c/Users/UserName/Documents /cygdrive/c/Users/UserName/Contacts') |
- | --> set srcpath=/cygdrive/c/Users/WindowsUserID/Contacts /cygdrive/c/Users/WindowsUserID/Documents /cygdrive/c/Users/WindowsUserID/Favorites /cygdrive/c/Users/WindowsUserID/Pictures /cygdrive/c/Users/WindowsUserID/Videos /cygdrive/c/Users/WindowsUserID/Wav | + | Rem set srcpath='/cygdrive/c/Users/UserName/Contacts /cygdrive/c/Users/UserName/Documents /cygdrive/c/Users/UserName/Favorites /cygdrive/c/Users/UserName/Pictures /cygdrive/c/Users/UserName/Videos /cygdrive/c/Users/UserName/Wav' |
</code> | </code> | ||
- | ==== Work in progress.... ==== | + | |
+ | ==== Schedule The Backup ==== | ||
+ | Using the Windows Task Scheduler add a task to run the Backup.bat batch file on a regular schedule basis. I've set mine to run daily at 7:00PM. | ||
+ | |||
+ | |||
+ | ===== End Results ===== | ||
+ | Upon initial run of the Backup.bat batch file a directory (Named with the current date and time) along with two files and a link named Current will be created. | ||
+ | \\ | ||
+ | \\ | ||
+ | The file named LastBkpDate.dat contains the name of folder that was created during the last backup. The batch file uses this information to determine the location of the last backup. This information is in-turn passed to RSync so it may establish appropriate hardlinks when performing the next backup. Do not modify this file or RSync will not create the hardlinks correctly. | ||
+ | \\ | ||
+ | \\ | ||
+ | The file named snapshot.log contains detail pertaining to the backup. Depending on the number of files being stored the initial entry may be large. Subsequent entries will reflect only those files changed since the last backup was performed. | ||
+ | \\ | ||
+ | \\ | ||
+ | The link named Current will take you to the last backup directory. | ||
+ | \\ | ||
+ | \\ | ||
+ | {{howto:backup:backup_-_pc:backedupfiles.png|}} | ||
+ | \\ | ||
+ | |||
+ | Enjoy ! | ||