DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2007-06-14 18:31:06

jduncan
New member
Registered: 2007-06-14
Posts: 3

Backup to 2nd DNS-323

Hi there,

First I want to declare I had never used Unix/Linux previously until I started playing with my DNS-323 recently. I have successfully setup the fun_plug and telnet access. I then created a new smb.conf file, copied it to the DNS-323 HDD and via the fun_plug restart the samba to use this new config file.

As my experiences with the DNS-323 have proved very positive I decided to purchase a 2nd unit for backup purposes. Both units have 2x 500GB SATA HDD's running in RAID1 mode. However, as the data being stored on the first DNS-323 unit is mission critical I want to run a nightly backup script to copy all of the data from the 1st DNS-323 to the 2nd DNS-323 unit. The 2nd DNS-323 unit is to be used purely for backup purposes and will eventually be located at a different site connected by the WAN.

I have several questions:

1) I believe I will need to create a CRON job to run the backup script at a pre-determined time on a daily basis? How do I do this?
2) Is rsync the best option for my purposes (I have rsync v2.6.9 pre3 on the first DNS-323 unit)? The first example on the rsync website (see below) seems ideal for my needs but what do I need to change to get this working? Obviously the directory to backup will need to be changed but what would I enter for the password on the backup server?
3) Do I need to run anything on the 2nd DNS-323 unit?

Many thanks for all your help!

James


#!/bin/sh

# This script does personal backups to a rsync backup server. You will end up
# with a 7 day rotating incremental backup. The incrementals will go
# into subdirectories named after the day of the week, and the current
# full backup goes into a directory called "current"
# tridge@linuxcare.com

# directory to backup
BDIR=/home/$USER

# excludes file - this contains a wildcard pattern per line of files to exclude
EXCLUDES=$HOME/cron/excludes

# the name of the backup machine
BSERVER=owl

# your password on the backup server
export RSYNC_PASSWORD=XXXXXX


########################################################################

BACKUPDIR=`date +%A`
OPTS="--force --ignore-errors --delete-excluded --exclude-from=$EXCLUDES
      --delete --backup --backup-dir=/$BACKUPDIR -a"

export PATH=$PATH:/bin:/usr/bin:/usr/local/bin

# the following line clears the last weeks incremental directory
[ -d $HOME/emptydir ] || mkdir $HOME/emptydir
rsync --delete -a $HOME/emptydir/ $BSERVER::$USER/$BACKUPDIR/
rmdir $HOME/emptydir

# now the actual transfer
rsync $OPTS $BDIR $BSERVER::$USER/current

Offline

 

#2 2007-06-14 19:31:01

frodo
Member
From: Stockholm, Sweden
Registered: 2007-01-17
Posts: 259

Re: Backup to 2nd DNS-323

Have a look at rsnapshot. It is perfect for this.

http://www.rsnapshot.org/

Offline

 

#3 2007-06-15 13:49:35

jduncan
New member
Registered: 2007-06-14
Posts: 3

Re: Backup to 2nd DNS-323

This could be a good option once I have rsync working as rsnapshot requires additional files such as perl and ssh, etc. However, the rsync script i posted provides the same kind of functionality as rsnapshot...

I just need some help on getting rsync working in the first place with the mounts, ssh, etc.

Thanks

James

Offline

 

#4 2007-09-14 14:36:56

Chumby
Member
From: Tasmania, Australia
Registered: 2007-08-01
Posts: 96
Website

Re: Backup to 2nd DNS-323

Hi jduncan,

Did you work this one out?

I am looking at trying to copy everthing from one drive to the other... using rsync and cron, but no real idea how to do this at the moment (but I am experimenting).

Cheers
Chumby

Offline

 

#5 2007-09-14 15:10:23

dkl
Member
From: Toulouse
Registered: 2007-06-16
Posts: 104

Re: Backup to 2nd DNS-323

Hello,

I use rsync myself to backup everything weekly from my Linux PC to the RAID1 DNS: rsync daemon runs on the DNS (from Fonz' fun_plug), and a script that performs rsync through the network is run through cron on the PC. No need for any mount or shared point is needed fir this.

You surely can do the same from one DNS to the other one.
   - to use cron, "crontab -l" prints the list, "crontab -e" edits the list. "man crontab" for how-to, you just have to add one line to your crontab to run your backup script.
   - rsync through network: you need to have the daemon running on the "backup" device" (fun_plug...), and use the IP@ of this device in the rsync command. Again, "man rsync" for how-to.

A nice thing with rsync is the "backup" option: rsync keeps a dated copy of your modifications, including deletions. Thus, if you remove a file by error, you can recover it from the backups, even after a long period. Very useful.... Belts and braces.... and parachute!

Offline

 

#6 2007-10-01 11:36:30

Chumby
Member
From: Tasmania, Australia
Registered: 2007-08-01
Posts: 96
Website

Re: Backup to 2nd DNS-323

Hi Dkl,

Did you manage to get Crontab working OK?  I am just doing a manual rsync and it is working well... but cannot seem to get crontab going at all.

Cheers
Chumby

Offline

 

#7 2007-10-01 15:08:03

dkl
Member
From: Toulouse
Registered: 2007-06-16
Posts: 104

Re: Backup to 2nd DNS-323

Actually, I don't use crontab on the DNS323, but on the PC (as I wrote). But crontab should work also on the DNS. What have you tried exactly? Do you have any error?

Offline

 

#8 2007-10-01 15:11:42

Chumby
Member
From: Tasmania, Australia
Registered: 2007-08-01
Posts: 96
Website

Re: Backup to 2nd DNS-323

Yes there was an error - I tried it a while back, just can't remember what the error was but typing in the crontab command didn't work at all....It was like it couldn't be found or something.

I will try to get the exact error and will post....

Offline

 

#9 2007-10-01 15:22:24

Chumby
Member
From: Tasmania, Australia
Registered: 2007-08-01
Posts: 96
Website

Re: Backup to 2nd DNS-323

Hi dkl,

"man crontab" gives the error /mnt/HD_a2/fun.plug.d/bin/sh: man: not found

"crontab -l" seems to work... has three lines:
32 2 * * * /usr/sbin/rtc -s
30 2 2 * * /usr/sbin/rtc -c
59 1 * * * /usr/sbin/daylight&

"crontab -e" gives the same three lines, followed by a number of tildas, line after line.  I can't seem to add any new entries in anywhere.  After I run the command I just can't type anything...

I am using putty.

Thanks
Chumby

Offline

 

#10 2007-10-01 16:16:52

dkl
Member
From: Toulouse
Registered: 2007-06-16
Posts: 104

Re: Backup to 2nd DNS-323

Normally, "crontab -e" launches the *default* editor on the crontab file. This should be vi in your case. The "tildas" are just empty lines in vi... Do it again, go to the first tilda, and type "i" (insert), then type something to insert...."ESC" to go back to previous mode. Well, you need to know a bit of vi, of course....

Offline

 

#11 2007-10-02 00:13:08

Chumby
Member
From: Tasmania, Australia
Registered: 2007-08-01
Posts: 96
Website

Re: Backup to 2nd DNS-323

Hi dkl.. thanks for that.  I can get to the last ^M on the last entry but the cursor wont go down to the tilda.  Pressing i does get my into insert mode, but I still can't get to the start of a new tilda line.  Is there any good documentation on "vi".  Any other thoughts?

Offline

 

#12 2007-10-02 10:59:19

dkl
Member
From: Toulouse
Registered: 2007-06-16
Posts: 104

Re: Backup to 2nd DNS-323

Sorry, I made a mistake, you cannot "edit" neither put the cursor on the tilda.

So: go to the end of the last line. Press "a", you are then in "append" mode.  Type ENTER at that point, you insert a new line :smile... Then type you line....
To exit from "editing mode", type ESC.
Then
  ":wq" will save you file and exit vi (":x" will do the same).
  ":q" will leave vi without saving

I suggest that you make some "rehearsal" tests on a dummy "/tmp/test" file before going into crontab edition....

I have no prefered link here to any "VI" how-to, sorry (I'm myself a VERY basic user of VI, much happier with GNU-Emacs) but I'm sure you can find this on the net.

Offline

 

#13 2007-10-02 11:14:14

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: Backup to 2nd DNS-323

There's also joe, which should be easier to get started with.

Offline

 

#14 2007-10-20 06:39:53

Chumby
Member
From: Tasmania, Australia
Registered: 2007-08-01
Posts: 96
Website

Re: Backup to 2nd DNS-323

Thanks dkl/fonz,

So if I can now edit the crontab, what do I need to put in to run a script to backup everythign from one disk to the anoter, say at 2pm each night?

Thanks
Chumby

Offline

 

#15 2007-10-22 06:35:21

Chumby
Member
From: Tasmania, Australia
Registered: 2007-08-01
Posts: 96
Website

Re: Backup to 2nd DNS-323

Might have found the way... will try tonight...

From: http://www.mikerubel.org/computers/rsync_snapshots/

To run the rsync-with-backup command from the previous section every morning at 4:20 AM, for example, edit the root cron table: (as root)

crontab -e

Then add the following line:

20 4 * * * rsync -a --delete source/ destination/

Finally, save the file and exit. The backup will happen every morning at precisely 4:20 AM, and root will receive the output by email. Don't copy that example verbatim, though; you should use full path names (such as /usr/bin/rsync and /home/source/) to remove any ambiguity.

Offline

 

#16 2007-10-22 23:53:11

Chumby
Member
From: Tasmania, Australia
Registered: 2007-08-01
Posts: 96
Website

Re: Backup to 2nd DNS-323

Didn't seem to work for me.  I have reset the dns so will see if that makes a difference. 

Do I have the right path to rsync or should I use as it says above /usr/bin/rsync/ ?

Thanks,
Chumby

Offline

 

#17 2007-10-23 10:28:05

dkl
Member
From: Toulouse
Registered: 2007-06-16
Posts: 104

Re: Backup to 2nd DNS-323

I suggest that you insert, in a shell script, the command for rsyncing your system. Maybe this script will have only one line, but this allows you to test it before moving to crontab. Moreover, if you intend to make modifications to your rsync function in the future, you just have to edit and save this script, without going back to "crontab stuff". Once you are sure your script is OK, just insert the call to this script in your crontab.
Example:
- /mnt/HDa2/backup.sh could be the name of your script. It should contain, at least one line which actually performs the rsync. Use absolute pathes. "which rsync" will give you the path to rsync.
- make the script executable: "chmod 755 /mnt/HDa2/backup.sh"
- check it works by running it
- once you are sure your script is OK, insert this line in the crontab: "20 4 * * * /mnt/HDa2/backup.sh"

Offline

 

#18 2007-10-23 10:45:28

Chumby
Member
From: Tasmania, Australia
Registered: 2007-08-01
Posts: 96
Website

Re: Backup to 2nd DNS-323

Hi dkl,

Thanks very much for this... I will give it a go - I think I am on track.

When I tried to edit the crontab as you say above, it saved OK, but then on reboot it was gone.  I found a little script on this thread:

http://dns323.kood.org/forum/p1642-2007 … html#p1642

which reloads the entry everytime the dns reboots.  Going to try that now.

One other thing though - I am in Australia - how do I change the timezone to make sure it reflects the time here?

I will let you know how I go...

Cheers,
Chumby.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB