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

#276 2009-05-24 13:40:01

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

Re: Tutorial: Backup Everything from Vol A to Vol B once a night

Hello
Rsync is very efficient comparing 2 existing folders (src & dst) and building a difference list. Using a separate destination path each time like you do is not the regular way to use rsync. More basically, you could have only ONE destination path (for example "/mnt/HD_b2/Backup_NAS/current"), so that you have in this directory an exact mirror of your "last backup" src folder. The way you do it is not efficient in terms on disk space (everything is copied each time, I think), neither in terms of CPU usage.

I would suggest you to use /mnt/HD_b2/Backup_NAS/current as single destination (dstpath), and have a "--backup=/mnt/HD_b2/Backup_NAS/backup/`date"` to let rsync store separately what is not anymore in your "current" dest folder.

Offline

 

#277 2009-05-28 02:27:17

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

Re: Tutorial: Backup Everything from Vol A to Vol B once a night

Hi all,

dkl... I have added your suggestions to the improvements and it is working of sorts. 

There are a couple of issues however. Only one folder is being created in the rsync_backup folder (a new folder is ment to be created for each day.. right?).

All that is coming up at the moment is one folder with the date string (as per the code), not the actual date.   No other folders are created for the next day. I suspect it may be an issue with the ' or "'s in the wrong place.  Can you see what may be wrong?

Cheers
Chumby

Offline

 

#278 2009-05-28 09:07:05

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

Re: Tutorial: Backup Everything from Vol A to Vol B once a night

1) I think a new folder is created only if something has to be put in... (i.e file(s) have been deleted or changed since last time). "Empty" backup folders are not created (I think, I'm not 100% sure, I have to check)
2) yes, obviously, ' and " are inverted in my example above.

   "--backup=/mnt/HD_b2/Backup_NAS/backup/`date`" should be used instead....

Offline

 

#279 2009-05-28 10:34:51

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

Re: Tutorial: Backup Everything from Vol A to Vol B once a night

Hi dkl,

Thatsnks for that.

This is the line in the tut that I can't get the date bit working... tried the ' and "s the other way also... can you see a problem below?

Code:

/bin/echo "5 2 * * * /mnt/HD_a2/ffp/bin/rsync -av --delete  --backup --backup-dir=../backup_rsync_save/`date +%Y-%m-%d` /mnt/HD_a2/* /mnt/HD_b2/rsync_save >> /mnt/HD_a2/ffp/log/rsync.last.log 2>&1" >> $CRONTXT

Cheers
Chumby

Offline

 

#280 2009-05-28 12:49:25

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

Re: Tutorial: Backup Everything from Vol A to Vol B once a night

I see what you mean now.

This is not exactly the way it works at home. I have made a separate script, (synchronise.sh) which makes the job. My crontab contains only the call to the script. From my point of view, this is better than putting everything in the crontab: easier to check, modify, etc....
Maybe there could be an issue with the evaluation of `date ....` the way it is done here. This has to be checked.

Offline

 

#281 2009-05-28 23:07:45

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

Re: Tutorial: Backup Everything from Vol A to Vol B once a night

I think that evaluation of `date...` might be the issue (PATH and/or 'quote' management). Anyway, I don't like to put anything but simple code in the crontab. So let's do it simple and clean (I hope). The way I would recommend is to make a separate script (call it what you want), mine is /mnt/HD_a2/fun_plug.d/bin/synchronise.sh

So my crontab is

32 2 * * * /usr/sbin/rtc -s
30 2 2 * * /usr/sbin/rtc -c
59 1 * * * /usr/sbin/daylight &
5 2 * * * /mnt/HD_a2/fun_plug.d/bin/synchronise.sh

And synchronize.sh (must be executable, of course) should look like:

#!/bin/sh
#
# synchronize folders between Volume_1 and Volume_2
# nightly script run by crontab
export PATH=/mnt/HD_a2/fun_plug.d/bin:/usr/bin:/bin:/usr/sbin:/sbin

echo `date` > /mnt/HD_a2/fun_plug.d/log/rsync.last.log
rsync -rlptDv --delete --exclude=<path-to-exclude>  --backup --backup-dir=/mnt/HD_b2/backup_rsync_save/`date +%Y-%m-%d` /mnt/HD_a2/* /mnt/HD_b2/rsync_save >> /mnt/HD_a2/fun_plug.d/log/rsync.last.log 2>&1

# clean backups
find /mnt/HD_b2/backup_rsync_save -type d -name "20[0-9]*-[0-9]*-[0-9]*" -mtime +60 | xargs rm -rf

Hope this helps

Offline

 

#282 2009-05-29 10:30:44

knireis
Member
Registered: 2007-12-10
Posts: 231

Re: Tutorial: Backup Everything from Vol A to Vol B once a night

dkl wrote:

And synchronize.sh (must be executable, of course) should look like:

#!/bin/sh
#
# synchronize folders between Volume_1 and Volume_2
# nightly script run by crontab
export PATH=/mnt/HD_a2/fun_plug.d/bin:/usr/bin:/bin:/usr/sbin:/sbin

echo `date` > /mnt/HD_a2/fun_plug.d/log/rsync.last.log
rsync -rlptDv --delete --exclude=<path-to-exclude>  --backup --backup-dir=/mnt/HD_b2/backup_rsync_save/`date +%Y-%m-%d` /mnt/HD_a2/* /mnt/HD_b2/rsync_save >> /mnt/HD_a2/fun_plug.d/log/rsync.last.log 2>&1

# clean backups
find /mnt/HD_b2/backup_rsync_save -type d -name "20[0-9]*-[0-9]*-[0-9]*" -mtime +60 | xargs rm -rf

Hope this helps

I assume the +60 in the last line is 60 days?

Offline

 

#283 2009-05-29 11:34:06

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

Re: Tutorial: Backup Everything from Vol A to Vol B once a night

yes it is. This was described through an earlier post. You can decide how long you want to keep your "oldies" this way...

Again, this works on funplug 1.03 (I'm still on this old version). If some folder names (/mnt/HD_a2/fun_plug.d/bin,  /mnt/HD_a2/fun_plug.d/log, ...) have been changed in ffp, it must be adapted!

Offline

 

#284 2009-05-29 11:43:36

knireis
Member
Registered: 2007-12-10
Posts: 231

Re: Tutorial: Backup Everything from Vol A to Vol B once a night

Thanks, I just wonder how to change the editcron.sh file so the synchronize.sh script is added to the cron

Offline

 

#285 2009-05-29 18:09:37

Loose Gravel
Member
Registered: 2008-10-14
Posts: 50

Re: Tutorial: Backup Everything from Vol A to Vol B once a night

Opps, wrong thread. Sorry

Last edited by Loose Gravel (2009-05-29 18:10:42)

Offline

 

#286 2009-05-29 19:50:57

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

Re: Tutorial: Backup Everything from Vol A to Vol B once a night

I think this described at the beginning of this tutorial, you just have to change the line to be put in crontab....

Offline

 

#287 2009-08-06 05:56:46

kring
Member
Registered: 2008-02-13
Posts: 13

Re: Tutorial: Backup Everything from Vol A to Vol B once a night

I see that you have changed the code to now use a rsync_save folder, I have been running on an older script... This is a nice addition.

One request if possible, could you also provide some code like dlk has in his seperate script to wipe out files & folders in the rsync_save folder that are older then a certain date or number of days so this folder does not get out of control and require manual maintenance... i.e. each day it does a scan for files older then 30 days and deletes permanently?

Last edited by kring (2009-08-07 15:06:26)

Offline

 

#288 2009-08-07 14:43:16

kring
Member
Registered: 2008-02-13
Posts: 13

Re: Tutorial: Backup Everything from Vol A to Vol B once a night

Now I'm not sure I like this rsync_save option because essentially all it does is double the backup on the VOLB drive. by your description it sounds like if I were to delete a file on VolumeA, and then the job kicked off to sync VolA to VolB When it identified the missing file on VolA it would move that file from VolB backup to the VolB rsync_save folder. so that way it could be retrieved instead of wiped from both VolA & VolB.... But that's not what this command does.... it appears to simply just make 2 total mirior copies of VolA of which it does not sync the rsync_save folder, letting it grow endlessly with no management of size...

Esentially this new script requires your VolB drive to be at minimum twice the physical size of VolA....  you should mention that at the top post, because I would guess most people have two matching hard drives and there for VolB will fill up and no longer work.

Could you please confirm exactly how I remove this rync_save option?

Offline

 

#289 2009-08-08 07:51:55

psykad
New member
Registered: 2008-03-16
Posts: 2

Re: Tutorial: Backup Everything from Vol A to Vol B once a night

I have to thank you again Chumby for this idea and everyone else who has contributed. I've been using it for quite awhile with FFP v1.3 and had the original editcron.sh back in 2007. I prefer this code over what is currently used. Now, this has worked flawless for me until now. I've upgraded to FFP v1.5 and I decided to use dkl's method having the rsync code separate from the editcron.sh. The only problem is that the syncfiles.sh script that I made wont' execute via the crontab. It does work, though, I have to manually run it. I'm a newbie when it comes to linux scripting. What am I doing wrong? Is it a problem with FFP v1.5?

/mnt/HD_a2/ffp/start/editcron.sh

Code:

#!/bin/sh

CRONTXT=/mnt/HD_a2/crontab.tx

/bin/crontab -l > $CRONTXT

/bin/echo "0 6 * * * /mnt/HD_a2/ffp/bin/syncfiles.sh" >> $CRONTXT

/bin/crontab $CRONTXT

/bin/rm $CRONTXT

/mnt/HD_a2/ffp/bin/syncfiles.sh

Code:

#!/bin/sh

/mnt/HD_a2/ffp/bin/rsync -rlptDv --delete /mnt/HD_a2 /mnt/HD_b2 >/mnt/HD_a2/ffp/log/rsync.last.log 2>&1

*EDIT*
It works now!

Last edited by psykad (2009-08-10 06:10:06)

Offline

 

#290 2010-09-17 18:57:45

stevelucky
Member
Registered: 2010-09-14
Posts: 15

Re: Tutorial: Backup Everything from Vol A to Vol B once a night

While it took me a while to get setup (I'm pretty new to this stuff), the walk-through was AWESOME. It totally helped me out. It should be noted that there appears to be a syntax error in the code, however, while setting up the editcron.sh script:

Code:

/mnt/HD_a2/ffp/bin/rsync -av --delete  --backup --backup-dir=..

There's 2 spaces between "--delete" and "--backup", when I think there should only be one. This throws the whole thing off, at least it did for me.

Offline

 

#291 2011-04-08 15:35:43

Geofract
New member
Registered: 2011-04-08
Posts: 3

Re: Tutorial: Backup Everything from Vol A to Vol B once a night

Hi, thanks to people that wrote this script, and for providing the tutorial, etc.

I am new to all this, and struggling a little. If some kind soul could help it would be much appreciated.

When I look at ffp.log, there is an error in the last part:

/ffp/start/editcron.sh ...
/ffp/start/editcron.sh: line 1: #!/bin/sh: not found

And consequently my crontab -l results are wrong, but I do have 4 listings rather than 3. I have managed to get rysnc working manually though, and successfully copied files between drives this morning.

Crontab -l results:

59 1 * * * /usr/sbin/daylight&
30 2 * * * /usr/sbin/stime&
32 2 * * * /usr/sbin/rtc -s
30 2 2 * * /usr/sbin/rtc -c

I'm using ffp 0.5 and Firmaware V1.09.

I created the editcron.sh file via notepad++ because I had problems with the vi editor. I chmod' a bunch of files in /ffp/start/ to 777 so I could write to the files direct from notepad++. Not sure if that was wise? But at least mediatomb still works after having files edited via notepad++.

Anyhow, I am stuck, as I don't understand the error in the ffp.log, so I can't get the cron job working.

Any guidance much appreaicted.

Offline

 

#292 2011-04-09 04:07:19

bound4h
Member
Registered: 2010-04-12
Posts: 209

Re: Tutorial: Backup Everything from Vol A to Vol B once a night

chmod 777 your /ffp/start is fine. 

The error looks like its telling you to put your she-bang, or #!/bin/sh, at the top of your script.  Try adding that as the first line of your editcron.sh script and the run: ./ffp/start/editcron.sh and then run crontab -l and see if it's there.

Offline

 

#293 2011-04-09 07:25:41

halfsoul
Member
Registered: 2008-01-28
Posts: 57

Re: Tutorial: Backup Everything from Vol A to Vol B once a night

I have a slightly different and yet slightly similar situation.  My editcron script does not error out:

Code:

* /ffp/start/editcron.sh ...
*  OK

And my rsync jobs finish just fine:

Code:

sent 132101211 bytes  received 7427 bytes  727871.28 bytes/sec
total size is 580455520037  speedup is 4393.77

BUT, my crontab does reset on its own.  I've gotten in the habit of manually re-running the editcron.sh script once or twice per week to ensure the mirroring continues:

Code:

~# crontab -l
59 1 * * * /usr/sbin/daylight&
30 2 * * * /usr/sbin/stime&
32 2 * * * /usr/sbin/rtc -s
30 2 2 * * /usr/sbin/rtc -c
~# /ffp/start/editcron.sh
~# crontab -l
59 1 * * * /usr/sbin/daylight&
30 2 * * * /usr/sbin/stime&
32 2 * * * /usr/sbin/rtc -s
30 2 2 * * /usr/sbin/rtc -c
5 2 * * * /mnt/USB/ffp/bin/rsync -av --delete /mnt/HD_a2 /mnt/HD_b2 >> /mnt/USB/log/rsync.last.log 2>&1

Also on ffp 0.5 (~June 2010) and firmware 1.09.

Can anyone else confirm their crontab is "forgetting"?
Does anyone have ideas for resolution?

Offline

 

#294 2011-04-09 12:24:54

Geofract
New member
Registered: 2011-04-08
Posts: 3

Re: Tutorial: Backup Everything from Vol A to Vol B once a night

bound4h wrote:

chmod 777 your /ffp/start is fine. 

The error looks like its telling you to put your she-bang, or #!/bin/sh, at the top of your script.  Try adding that as the first line of your editcron.sh script and the run: ./ffp/start/editcron.sh and then run crontab -l and see if it's there.

Thanks for the reply. Line 1 was in place, but viewing it with vi via SSH revealed 3 dots '...' prior to #!/bin/sh - so I managed to fix that in VI. Crontab -l then showed up as expected.

Then I restarted the dns 323, and checked crontab -l again, and was suprised to find no job scheduled!

Looking through the ffp.log, editcron.sh loads without error, but rsyncd.sh is looking for a file /ffp/etc/rsyncd.conf, and so it seems rsyncd.sh doesn't start correctly. But there is no such file /ffp/etc/rsyncd.conf. There isn't such a file in the original tarball of FFP 0.5 either.

Just to confirm the loading problem, I typed sh rsyncd.sh start, and got this:

root@DNS-323:/mnt/HD_a2/ffp/start# sh rsyncd.sh start
/ffp/etc/rsyncd.conf: Required file not found or not readable

I guess I need a config file... but what to write in it? Any ideas please? Unless the problem is elsewhere.

Offline

 

#295 2011-04-09 13:34:04

FunFiler
Member
Registered: 2010-05-23
Posts: 577

Re: Tutorial: Backup Everything from Vol A to Vol B once a night

halfsoul wrote:

Can anyone else confirm their crontab is "forgetting"?
Does anyone have ideas for resolution?

I had a similar issue. I resolved it by putting a 3 minute delay in the script. It seems that the cron jobs reinitialize on startup after a few minutes and this resolved it, at least for me and a few others.

Code:

# Add a delay to work around a bootup timing issue
echo "Adding a 3 minute startup delay"
/ffp/bin/sleep 3m

Since you (hopefully) don't reboot that often, a 3 minute delay doesn't really affect anything else.

You say you rerun the script once or twice a week, you could of course add it as a cron job just to be sure and have it run daily smile I'm betting though that a delay will resolve it. It works for me at least.

Last edited by FunFiler (2011-04-09 13:42:40)


3 * (DNS-323 with 2 * 2TB) = 12TB Running FW v1.08 & FFP v0.5
Useful Links: Transmission, Transmission Remote, Automatic

Offline

 

#296 2011-04-09 13:37:58

FunFiler
Member
Registered: 2010-05-23
Posts: 577

Re: Tutorial: Backup Everything from Vol A to Vol B once a night

Geofract wrote:

I guess I need a config file... but what to write in it? Any ideas please? Unless the problem is elsewhere.

Mine looks like this:

Code:

host allow = 192.168.1.0/24
log file = /mnt/usb/logs/rsyncd.log
uid = root
gid = root
read only = no
[archive]
path = /mnt/HD_a2/Archive
[web]
path = /mnt/HD_a2/web

3 * (DNS-323 with 2 * 2TB) = 12TB Running FW v1.08 & FFP v0.5
Useful Links: Transmission, Transmission Remote, Automatic

Offline

 

#297 2011-04-09 19:09:31

Geofract
New member
Registered: 2011-04-08
Posts: 3

Re: Tutorial: Backup Everything from Vol A to Vol B once a night

Thanks FunFiler.

conf file in place, and all is good. I had to add the 3m delay too. It's all working now I think! smile

Offline

 

#298 2011-04-11 06:21:56

halfsoul
Member
Registered: 2008-01-28
Posts: 57

Re: Tutorial: Backup Everything from Vol A to Vol B once a night

FunFiler wrote:

halfsoul wrote:

Can anyone else confirm their crontab is "forgetting"?
Does anyone have ideas for resolution?

I had a similar issue. I resolved it by putting a 3 minute delay in the script. It seems that the cron jobs reinitialize on startup after a few minutes and this resolved it, at least for me and a few others.

Code:

# Add a delay to work around a bootup timing issue
echo "Adding a 3 minute startup delay"
/ffp/bin/sleep 3m

Since you (hopefully) don't reboot that often, a 3 minute delay doesn't really affect anything else.

You say you rerun the script once or twice a week, you could of course add it as a cron job just to be sure and have it run daily smile I'm betting though that a delay will resolve it. It works for me at least.

Thanks for the reply.

Are you saying you added a three minute delay to the editcron script?  If so, it seems that would be effective for the crontab not being updated after a reboot.  My situation is that the rsync item appears correctly after every reboot and then disappears from the crontab list without any reboot.  It simply vanishes.  I add it again by re-running the script, and then after some amount of time it vanishes again.

Offline

 

#299 2011-04-16 15:00:32

bfg100k
Member
Registered: 2007-09-15
Posts: 55

Re: Tutorial: Backup Everything from Vol A to Vol B once a night

halfsoul wrote:

FunFiler wrote:

halfsoul wrote:

Can anyone else confirm their crontab is "forgetting"?
Does anyone have ideas for resolution?

I had a similar issue. I resolved it by putting a 3 minute delay in the script. It seems that the cron jobs reinitialize on startup after a few minutes and this resolved it, at least for me and a few others.

Code:

# Add a delay to work around a bootup timing issue
echo "Adding a 3 minute startup delay"
/ffp/bin/sleep 3m

Since you (hopefully) don't reboot that often, a 3 minute delay doesn't really affect anything else.

You say you rerun the script once or twice a week, you could of course add it as a cron job just to be sure and have it run daily smile I'm betting though that a delay will resolve it. It works for me at least.

Thanks for the reply.

Are you saying you added a three minute delay to the editcron script?  If so, it seems that would be effective for the crontab not being updated after a reboot.  My situation is that the rsync item appears correctly after every reboot and then disappears from the crontab list without any reboot.  It simply vanishes.  I add it again by re-running the script, and then after some amount of time it vanishes again.

I have the same problem! When I check the syslogs, it appears that crond is restarted on a daily basis. The problem is that the restart is not at the same time everyday... really weird...

Offline

 

#300 2011-04-16 20:59:22

FunFiler
Member
Registered: 2010-05-23
Posts: 577

Re: Tutorial: Backup Everything from Vol A to Vol B once a night

The delay on startup is all that my 2 systems require. After that, the cron daemon stays active with the correct content. What other services are you running? Maybe one of them is causing cron to die.


3 * (DNS-323 with 2 * 2TB) = 12TB Running FW v1.08 & FFP v0.5
Useful Links: Transmission, Transmission Remote, Automatic

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB