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 2010-08-26 21:28:47

TangoMan
Member
Registered: 2010-08-26
Posts: 7

Running rsyncd On DNS-321

I've seen posts about using rsync with a DNS-321, but it seems people are talking about just using rsync.  I've been searching, but I'll also admit I could have missed something.

I'd like to run rsyncd on my DNS-321 so I can backup to it.  I have a few systems that have been backing up to a server, but want them to use the NAS now and, for many reasons, it'd be really tough to re-configure all of them.

I see Fun Plug has rsync included, but not rsyncd.

1) Is it possible to get rsyncd on the DNS-321?  If so, where?

2) What would I modify to get it started on startup?

3) Would rsyncd.conf go in /etc or in /ffp/etc?

Thanks for any help on this!

Offline

 

#2 2010-08-26 23:05:24

scaramanga
Member
Registered: 2010-08-04
Posts: 251

Re: Running rsyncd On DNS-321

rysncd is included in ffp. If not in the basic ffp install, as an additional package.
The wiki is your friend. See here and here.
And also this: http://www.aboutmyip.com/AboutMyXApp/DeltaCopy.jsp

Last edited by scaramanga (2010-08-26 23:07:39)


DNS-323 HW Rev. C1 FW 1.10 fun-plug 0.5
2 x WD10EARS-00Y5B1 in Standard mode (LCC set to 5 min; Aligned to 4K)
Transmission with Transmission Remote GUI

Offline

 

#3 2010-08-27 07:25:42

TangoMan
Member
Registered: 2010-08-26
Posts: 7

Re: Running rsyncd On DNS-321

Thanks!

I've been searching the Wiki, but I'm still getting used to everything.  I had seen a number of pages about using rsync, but some (including a page or two on other sites) were talking about running rsyncd on the client computer (making it, really, a server).  It's up and running now, which is a huge relief.

I had searched for the actual executable rsyncd and not found it, so I took it that the daemon wasn't available on the device.  Now everything is working just fine.  Thanks for the help!

Offline

 

#4 2010-08-27 11:59:06

scaramanga
Member
Registered: 2010-08-04
Posts: 251

Re: Running rsyncd On DNS-321

TangoMan wrote:

Thanks!

I've been searching the Wiki, but I'm still getting used to everything.  I had seen a number of pages about using rsync, but some (including a page or two on other sites) were talking about running rsyncd on the client computer (making it, really, a server).  It's up and running now, which is a huge relief.

With rsync it's up to you to decide how the backup/snapshot happens. Either your PC pushes the data to the DNS-323 (you'll need rsyncd configured and running for that) or the DNS-323 pulls the data from the PC. In the latter case (which I think is better) the PC is, indeed, the server.
The reason I think the second option is better is because it allows you to control (timing, load on DNS-323, network load) the backup/snapshot of multiple PCs from a single place.

Last edited by scaramanga (2010-08-27 12:01:07)


DNS-323 HW Rev. C1 FW 1.10 fun-plug 0.5
2 x WD10EARS-00Y5B1 in Standard mode (LCC set to 5 min; Aligned to 4K)
Transmission with Transmission Remote GUI

Offline

 

#5 2010-08-27 14:28:16

TangoMan
Member
Registered: 2010-08-26
Posts: 7

Re: Running rsyncd On DNS-321

I can see that: I like the idea of having all the control functions in one place, but, in the long run, I'm slimming down because I'm burned out from years of running my own software based business.  I'm working on, in part, reducing the number of systems on my LAN.  The OS X based systems will use Time Machine, so I don't even have to think about that, and, eventually, I'll only have one Linux system using rsync.  That system needs to be self contained for a number of reasons, so it'll work better if all I ever have to do is change the rsync host name in it's database when I make changes to the LAN.  I'm also hoping, at some point, to sell the business, and if I can provide someone with a system that just needs something like an NAS for backup, or one that can just as easily backup to off-site, it helps me sell it.  (And I'm doing that with everything on it: the system will have an install disk and any services it uses will be easy to configure by just answering a few questions.)

Offline

 

#6 2010-08-28 11:43:21

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

Re: Running rsyncd On DNS-321

After reading this thread I was prompted to go and setup rsync on my 2 DNS323s as well. No issues as Fonz includes it in ffp.

I use both "push" and "pull" for various tasks and having the flexibility of running the daemon is great.

I decided to setup to check for updated ffp packages once a week automatically. The only issue I had was with adding the crontab jobs. On a reboot there seems to be some sort of timing issue. I added a script to append the new jobs but if I telnet in during bootup, I see the new jobs are added, then a few seconds later they are gone again. I added a 5 minute sleep to my script and that seems to have worked  but I didn't notice anyone else running into this issue.

Last edited by FunFiler (2010-08-28 11:46:08)


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

Offline

 

#7 2010-08-28 15:02:43

scaramanga
Member
Registered: 2010-08-04
Posts: 251

Re: Running rsyncd On DNS-321

Here's my version of the editcron.sh script. It goes in the /ffp/start folder.
Make sure you use an editor that supports *nix-style line-breaks when you copy it, and set the permissions to execute.

It supports using the start/stop/restart/status commands, and it is safe to use start multiple time (i.e. it will not make duplicate cron jobs.

Code:

#!/bin/sh

# PROVIDE: Editcron

#
# Schedule job
# Important: Always run "./editcron.sh stop" BEFORE making changes to job.
#            Otherwise, the old job will remain scheduled until you restart.
#
schedule="30 2 * * *"
job="/ffp/bin/snapshot.sh"

#
# Commands
#
grepcmd="/bin/grep"
crontabcmd="/bin/crontab"
rmcmd="/bin/rm"
echocmd="/bin/echo"

#
# Tempporary files
#
TMPDIR="/tmp"
TMPCRONTXT="${TMPDIR}/crontab.txt"
TMPOTHERCRONTXT="${TMPDIR}/othercrontab.txt"

#
# FFP Start Functions
#
. /ffp/etc/ffp.subr
start_cmd="editcron_start"
stop_cmd="editcron_stop"
status_cmd="editcron_status"

editcron_start()
{
    # grab existing crontab
    ${crontabcmd} -l > ${TMPCRONTXT}

    # check if already scheduled
    cronjobs=$(${grepcmd} "${job}" ${TMPCRONTXT})
    if test -n "${cronjobs}"; then
        ${echocmd} "${job} already scheduled:"
        ${echocmd} "${cronjobs}"
    else
        # add the cron job and install the new one
        ${echocmd} "Scheduling ${schedule} ${job}"
        ${echocmd} "${schedule} ${job}" >> ${TMPCRONTXT}
        ${crontabcmd} ${TMPCRONTXT}
    fi

    # clean up
    ${rmcmd} ${TMPCRONTXT}
}

editcron_stop()
{
    # grab existing crontab
    ${crontabcmd} -l > ${TMPCRONTXT}

    # check if already scheduled
    cronjobs=$(${grepcmd} "${job}" ${TMPCRONTXT})
    if test -z "${cronjobs}"; then
        ${echocmd} "${job} not scheduled"
    else
        # remove the cron job(s) and install the new one
        ${grepcmd} -v "${job}" ${TMPCRONTXT} > ${TMPOTHERCRONTXT} 
        ${crontabcmd} ${TMPOTHERCRONTXT} 
        ${echocmd} "${job} not longer scheduled"

        # clean up
        ${rmcmd} ${TMPOTHERCRONTXT} 
    fi

    # clean up
    ${rmcmd} ${TMPCRONTXT}
}

editcron_status()
{
    # grab existing crontab
    ${crontabcmd} -l > ${TMPCRONTXT}
    cronjobs=$(${grepcmd} "${job}" ${TMPCRONTXT})

    # check if already scheduled
    if test -n "${cronjobs}"; then
        ${echocmd} "${job} is scheduled:"
        ${echocmd} "${cronjobs}"
    else
        ${echocmd} "${job} not scheduled"
    fi

    # clean up
    ${rmcmd} ${TMPCRONTXT}
}

run_rc_command "$1"

Last edited by scaramanga (2010-08-28 15:05:19)


DNS-323 HW Rev. C1 FW 1.10 fun-plug 0.5
2 x WD10EARS-00Y5B1 in Standard mode (LCC set to 5 min; Aligned to 4K)
Transmission with Transmission Remote GUI

Offline

 

#8 2010-08-28 18:37:07

TangoMan
Member
Registered: 2010-08-26
Posts: 7

Re: Running rsyncd On DNS-321

FunFiler wrote:

...I added a script to append the new jobs but if I telnet in during bootup, I see the new jobs are added, then a few seconds later they are gone again. I added a 5 minute sleep to my script and that seems to have worked  but I didn't notice anyone else running into this issue.

Isn't this the same situation with other config files being re-written at boot?  I noticed that if I edit /etc/exports, then reboot, it's been reset to what it was.

Does anyone know what script/program resets system files like this or if there's a way to stop it?

Offline

 

#9 2010-08-28 21:17:30

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

Re: Running rsyncd On DNS-321

scaramanga - Thanks. My scripts work, yours are a bit prettier smile

TangoMan - The files come from the firmware / read only memory. The idea is that on startup, ffp and other scripts run to perform reconfigurations. One example is the script posted above by scaramanga. It modifies the cron jobs on bootup.

My issue is that even though my script runs, and I can see that the change was made (crontab -l), after a few more seconds the cron jobs get set back to default. It's a timing thing. The "sleep" option though is no big deal and solve the issue for me. Just mentioning it here in case someone else runs into the same problem and needs a solution.

On a side (off topic) note, I came across an app for my smart phone that is a Transmission GUI. Very cool to be able to add, manage, monitor the torrents from my phone smile

Last edited by FunFiler (2010-08-28 21:19:21)


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

Offline

 

#10 2010-08-28 23:18:20

TangoMan
Member
Registered: 2010-08-26
Posts: 7

Re: Running rsyncd On DNS-321

Fun Filer, I can see that with a lot of files, they're copying them from RAM, but /etc/exports HAS to be re-created from config info somewhere, since that gets modified by what a user enters in the web control panel.  It's not a dire need, but I do wish I could modify that file.  I guess, to do it, I'll have to do something like what you have: add a script that changes it back to what I want on boot.

Offline

 

#11 2010-08-28 23:47:57

scaramanga
Member
Registered: 2010-08-04
Posts: 251

Re: Running rsyncd On DNS-321

FunFiler wrote:

scaramanga - Thanks. My scripts work, yours are a bit prettier smile

Glad you liked it. Here's my snapshot script. It automagically keeps the latest seven snapshots.

I should've added it it's all based on http://dns323.kood.org/howto:backup#dai … me_machine

Code:

#!/bin/sh

############
# Settings #
############

# Set source and exculde rules to govern what should be backed-up.
srcPath="/mnt/HD_a2/Photos /mnt/HD_a2/Documents /mnt/HD_a2/ffp /mnt/HD_a2/downloads"
excludeRules="--exclude=/downloads/**.part"

# Set destination path, i.e. where should the backup be placed.
baseDstPath="/mnt/HD_b2/Backup_NAS"

rsyncOpts="-ahHvx --fuzzy --stats"

# What is the maximum number of backups to keep. If there are more,
# the oldest will be deleted.
maxSnapshotCount=7


###################
# Run Environment #
###################

# Set path to Fun_Plug files.
# Fun_Plug 3.0 or 4.0
# ffppath=/mnt/HD_a2/fun_plug.d
# Fun_Plug 5.0
ffppath=/ffp


#
# Commands
#
rsyncCmd="${ffppath}/bin/rsync"
dateCmd="/bin/date"
lsCmd="/bin/ls"
rmCmd="/bin/rm"
lnCmd="/bin/ln"
wcCmd="${ffppath}/bin/wc"
headCmd="/bin/head"
echoCmd="/bin/echo"
mkdirCmd="/ffp/bin/mkdir"


#
# Backup locations and file names
#
dstName=$(${dateCmd} "+%Y%m%d_%H;%M;%S")
dstPath="${baseDstPath}/${dstName}"
dstLog="${dstPath}/snapshot.log"
currLink="${baseDstPath}/current"


##########
# Backup #
##########

${mkdirCmd} -p ${dstPath}

${echoCmd} Executing ${rsyncCmd} ${rsyncOpts} --link-dest=${currLink} ${excludeRules} ${srcPath} ${dstPath} >> ${dstLog}
${echoCmd} "== ${rsyncCmd} log start ===================================" >> ${dstLog}

${rsyncCmd} ${rsyncOpts} --link-dest=${currLink} ${excludeRules} ${srcPath} ${dstPath} >> ${dstLog} 2>&1
rsyncRC=$?

${echoCmd} "== ${rsyncCmd} log end =====================================" >> ${dstLog}

if test ${rsyncRC} -eq 0; then
    ${rmCmd} ${currLink}
    ${lnCmd} -s ${dstName} ${currLink}
else
    ${echoCmd} "Something went wrong during backup (rc=${rsyncRC}). Current won't be updated." >> ${dstLog}
fi

######################
# Remove Old Backups #
######################

# Only delete old backups if current succeeded
if test ${currLink} -ef ${dstPath}; then

    cd ${baseDstPath}

    # Count how many backups there are, which is given by: ls -1A <base-dst-dir> | wc
    # subtract 1 for current link
    snapshotCount=$(( $(${lsCmd} -1A . | ${wcCmd} -l) - 1 ))

    if test ${snapshotCount} -gt ${maxSnapshotCount}; then

        # Please note that the output from ls is sorted in the correct order
        snapshotRemoveCount=$(( ${snapshotCount} - ${maxSnapshotCount} ))
        snapshotRemove=$(${lsCmd} -1A . | ${headCmd} -n ${snapshotRemoveCount})

        ${echoCmd} "Removing the ${snapshotRemoveCount} oldest snapshot(s):" >> ${dstLog}
        ${echoCmd} "${snapshotRemove}" >> ${dstLog}
        ${rmCmd} -r ${snapshotRemove} >> ${dstLog} 2>&1
    else
        ${echoCmd} "Found ${snapshotCount} snapshot(s) where ${maxSnapshotCount} allowed. None removed." >> ${dstLog}
    fi
else
    ${echoCmd} "No snapshot(s) were removed." >> ${dstLog}
fi

Edit: Updated to my latest version, including exclude rules, slightly easier modifying rsync options.

Last edited by scaramanga (2011-02-13 21:18:49)


DNS-323 HW Rev. C1 FW 1.10 fun-plug 0.5
2 x WD10EARS-00Y5B1 in Standard mode (LCC set to 5 min; Aligned to 4K)
Transmission with Transmission Remote GUI

Offline

 

#12 2011-09-11 20:52:01

scaramanga
Member
Registered: 2010-08-04
Posts: 251

Re: Running rsyncd On DNS-321

Here's the latest iteration of my rsync script, which has some improvements/enhancements:
1. I added a post-backup command, which I use to email me the status of the backup and the log. If you'd like to set things up like that you'll need to configure msmtp/mutt (that's what I use). It's worth a different post. If anyone is interested let me know.
2. If a backup fails (=is incomplete) for any reason, the script will rename the backup directory so that it will be easy to see that. Also, now the script will keep the latest 7 complete backups. Previously, if a backup failed the oldest backup would not be deleted. But the next day, if the backup completes the two oldest backups were deleted. Now, the 7 latest complete backups would be kept.

Code:

#!/bin/sh

############
# Settings #
############

# Set source and exclude rules to govern what should be backed-up.
srcPaths="/mnt/HD_a2/Photos /mnt/HD_a2/Documents /mnt/HD_a2/ffp /mnt/HD_a2/downloads"
excludeRules="--exclude=/downloads/**.part"

# Set destination path, i.e. where should the backup be placed.
dstBasePath="/mnt/HD_b2/Backup_NAS"

rsyncOpts="-ahHix --fuzzy --stats"

# What is the maximum number of complete backups to keep. If there are more, 
# the oldest will be deleted.
maxSnapshotCount=7

# A command to-be executed after the backup operation is done. You can use the
# following variables in the command: 
#  RSYNC_EXIT_CODE  - The return code of rsync. Zero means success.
#  LOG_FILE         - The full-path to the log file.
#  DESTINATION_PATH - The full-path to the backup directory.
postBackupCmd='echo "Attached: snaptool log." | /usr/bin/mutt -n -F /ffp/usr/local/share/mutt/Muttrc -s "nas snapshot completed result[$RSYNC_EXIT_CODE]" -a $LOG_FILE my_email@gmail.com'

###################
# Run Environment #
###################

# Set path to Fun_Plug files.
# Fun_Plug 3.0 or 4.0
# ffpPath=/mnt/HD_a2/fun_plug.d
# Fun_Plug 5.0
ffpPath=/ffp


#
# Commands
#
rsyncCmd="${ffpPath}/bin/rsync"
dateCmd="/bin/date"
lsCmd="/bin/ls"
touchCmd="/bin/touch"
rmCmd="/bin/rm"
mvCmd="/bin/mv"
lnCmd="/bin/ln"
grepCmd="/bin/grep"
wcCmd="${ffpPath}/bin/wc"
headCmd="/bin/head"
echoCmd="/bin/echo"
mkdirCmd="/ffp/bin/mkdir"
awkCmd="${ffpPath}/bin/awk"

#
# Backup locations and file names
#
currentLinkName="current"
logFileName="snapshot.log"
failedBackupSufix="incomplete"

dstName=$(${dateCmd} "+%Y%m%d_%H%M%S")
dstPath="${dstBasePath}/${dstName}"
dstLog="${dstPath}/${logFileName}"
currLink="${dstBasePath}/${currentLinkName}"


##########
# Backup #
##########

${mkdirCmd} -p ${dstPath}

${echoCmd} "Executing ${rsyncCmd} ${rsyncOpts} --link-dest=${currLink} ${excludeRules} ${srcPaths} ${dstPath}" >> ${dstLog}
${echoCmd} "== ${rsyncCmd} log start ===================================" >> ${dstLog}

${rsyncCmd} ${rsyncOpts} --link-dest=${currLink} ${excludeRules} ${srcPaths} ${dstPath} >> ${dstLog} 2>&1
rsyncRC=$?

${echoCmd} "== ${rsyncCmd} log end =====================================" >> ${dstLog}

# This touch is not redundant. When getting files from a remote rsync daemon I noticed it sometimes modified the time of the
# destination directory to a value in the past. This screwed with the removal of old backups
${touchCmd} ${dstPath}

#######################
# Update Current Link #
#######################
if [ ${rsyncRC} -eq 0 ]; then
    ${rmCmd} ${currLink}
    ${lnCmd} -s ${dstName} ${currLink}
else
    ${echoCmd} "Something went wrong during backup (rc=${rsyncRC}). Current won't be updated." >> ${dstLog}
    ${echoCmd} "No snapshot(s) were removed." >> ${dstLog}

    # rename destination to mark it as an incomplete snapshot
    origDstPath=${dstPath}
    dstPath="${origDstPath}.${failedBackupSufix}"
    ${mvCmd} ${origDstPath} ${dstPath}
    dstLog="${dstPath}/${logFileName}"
fi

######################
# Remove Old Backups #
######################

cd ${dstBasePath}

# Count how many good backups there are
snapshotCount=$(${lsCmd} -1Atr . | ${grepCmd} -v ${currentLinkName} | ${grepCmd} -v "${failedBackupSufix}" | ${wcCmd} -l)

if [ ${snapshotCount} -gt ${maxSnapshotCount} ]; then

    # Please note that the output from ls is sorted in the correct order
    snapshotRemoveCount=$(( ${snapshotCount} - ${maxSnapshotCount} ))

    # What the code below does is list all snapshots ordered by date, then grabs
    # the N oldest (=first) good snapsthos and all incomplete snapshots
    # leading to them, where N is the number of snapshots to-be removed
    snapshotRemove=$(${lsCmd} -1Atr . | ${grepCmd} -v ${currentLinkName} | ${awkCmd} -v count=${snapshotRemoveCount} "! /${failedBackupSufix}/ { count--} {print} {if (count==0) exit 0};")

    ${echoCmd} "Removing the ${snapshotRemoveCount} oldest snapshot(s):" >> ${dstLog}
    ${echoCmd} "${snapshotRemove}" >> ${dstLog}
    ${rmCmd} -r ${snapshotRemove} >> ${dstLog} 2>&1
else
    ${echoCmd} "Found ${snapshotCount} snapshot(s) where ${maxSnapshotCount} allowed. None removed." >> ${dstLog}
fi

###########################
# Run Post Backup Command #
###########################

if [ -n "${postBackupCmd}" ]; then

    # Setup the post backup command run environment
    DESTINATION_PATH="${dstPath}"
    LOG_FILE="${dstLog}"
    RSYNC_EXIT_CODE="${rsyncRC}"

    ${echoCmd} "Executing ${postBackupCmd}" >> ${dstLog}
    eval ${postBackupCmd}
fi

exit ${rsyncRC}

Last edited by scaramanga (2011-09-11 21:02:51)


DNS-323 HW Rev. C1 FW 1.10 fun-plug 0.5
2 x WD10EARS-00Y5B1 in Standard mode (LCC set to 5 min; Aligned to 4K)
Transmission with Transmission Remote GUI

Offline

 

#13 2012-09-01 13:51:08

scaramanga
Member
Registered: 2010-08-04
Posts: 251

Re: Running rsyncd On DNS-321

I, finally, added a little how-to for setting-up email from command line. Unlike others who did that, it does not require you to install additional tools.
You can find it here: http://dns323.kood.org/forum/viewtopic.php?id=7133


DNS-323 HW Rev. C1 FW 1.10 fun-plug 0.5
2 x WD10EARS-00Y5B1 in Standard mode (LCC set to 5 min; Aligned to 4K)
Transmission with Transmission Remote GUI

Offline

 

#14 2012-09-05 11:24:12

scaramanga
Member
Registered: 2010-08-04
Posts: 251

Re: Running rsyncd On DNS-321

after a long LONG L-O-N-G time of use without any issues, I ran into a rare/weird problem using my rsync script. I can safely say this rare/weird problem can happen to you too, even if you're using the wiki script or some other tool.

What happened is that after cron started the snapshot backup, the built-in process that adjust the system clock to account for HW clock drift kicked-in and moved the system clock back in time. What happened next is that cron started the snapshot backup process a second time.
That caused two rsync processes to run at the same time trying to backup to the same location.

The rsync log(s) contained errors like:

Code:

rsync: failed to hard-link /mnt/HD_b2/Backup_NAS/current/ffp/share/man/man3/ASN1_OBJECT_free.3 with ffp/share/man/man3/ASN1_OBJECT_free.3: File exists (17)
rsync: symlink "/mnt/HD_b2/Backup_NAS/20120903_035001/ffp/share/man/man3/ASN1_OBJECT_free.3" -> "ASN1_OBJECT_new.3" failed: File exists (17)
...
rsync error: errors with program diagnostics (code 13) at hlink.c(548) [generator=3.0.9]
rsync: connection unexpectedly closed (14994 bytes received so far) [sender]
rsync error: errors with program diagnostics (code 13) at io.c(605) [sender=3.0.9]

(yes, I backup my ffp library)

and the rsync exit code(s) were 13 and 23

I've updated the snapshot script (added a simple lock file) to prevent this from happening. I'm testing it and will post the updated script soon.

Last edited by scaramanga (2012-09-05 11:27:51)


DNS-323 HW Rev. C1 FW 1.10 fun-plug 0.5
2 x WD10EARS-00Y5B1 in Standard mode (LCC set to 5 min; Aligned to 4K)
Transmission with Transmission Remote GUI

Offline

 

#15 2012-09-05 22:30:18

bjby
Member
Registered: 2009-02-22
Posts: 265

Re: Running rsyncd On DNS-321

I usually guard against this by listing running processes. Lock files often get into the "wrong" state unless you have some robust logic to clear them.

#exit if already running
RESULT=$(ps -ef | egrep 'lftp' | grep -v grep )
if [ -n "$RESULT" ] ; then
        echo already running...;
        exit 0;
fi

Offline

 

#16 2012-09-05 23:33:34

scaramanga
Member
Registered: 2010-08-04
Posts: 251

Re: Running rsyncd On DNS-321

bjby wrote:

I usually guard against this by listing running processes. Lock files often get into the "wrong" state unless you have some robust logic to clear them.

#exit if already running
RESULT=$(ps -ef | egrep 'lftp' | grep -v grep )
if [ -n "$RESULT" ] ; then
        echo already running...;
        exit 0;
fi

You've got a point. I'll do that instead.
Thanks!


DNS-323 HW Rev. C1 FW 1.10 fun-plug 0.5
2 x WD10EARS-00Y5B1 in Standard mode (LCC set to 5 min; Aligned to 4K)
Transmission with Transmission Remote GUI

Offline

 

#17 2012-09-06 11:08:59

scaramanga
Member
Registered: 2010-08-04
Posts: 251

Re: Running rsyncd On DNS-321

scaramanga wrote:

bjby wrote:

I usually guard against this by listing running processes. Lock files often get into the "wrong" state unless you have some robust logic to clear them.

#exit if already running
RESULT=$(ps -ef | egrep 'lftp' | grep -v grep )
if [ -n "$RESULT" ] ; then
        echo already running...;
        exit 0;
fi

You've got a point. I'll do that instead.
Thanks!

*sigh*, that doesn't work. Neither ps nor top in the busybox report correctly the entire command-line, only /ffp/bin/sh. No way to tell if the script is already running or not. Back to the lock file method.

Last edited by scaramanga (2012-09-06 11:20:48)


DNS-323 HW Rev. C1 FW 1.10 fun-plug 0.5
2 x WD10EARS-00Y5B1 in Standard mode (LCC set to 5 min; Aligned to 4K)
Transmission with Transmission Remote GUI

Offline

 

#18 2012-09-06 19:34:19

bjby
Member
Registered: 2009-02-22
Posts: 265

Re: Running rsyncd On DNS-321

There are lots of examples people writing lock file templates in bash, doing it more solid than my example maybe this one will work in ffp environment.

http://www.franzone.com/2007/09/23/how- … y-running/

Offline

 

#19 2012-09-06 20:07:29

scaramanga
Member
Registered: 2010-08-04
Posts: 251

Re: Running rsyncd On DNS-321

bjby wrote:

There are lots of examples people writing lock file templates in bash, doing it more solid than my example maybe this one will work in ffp environment.

http://www.franzone.com/2007/09/23/how- … y-running/

That's much smarter than what I wrote, with the $$ substitution for PID. I'm tempted to add that wink
(btw, do you use my script?)


DNS-323 HW Rev. C1 FW 1.10 fun-plug 0.5
2 x WD10EARS-00Y5B1 in Standard mode (LCC set to 5 min; Aligned to 4K)
Transmission with Transmission Remote GUI

Offline

 

#20 2012-09-07 00:10:35

bjby
Member
Registered: 2009-02-22
Posts: 265

Re: Running rsyncd On DNS-321

I do not use it, i do a weekly mirror rsync one disk to other.  I keep the mirror disk mounted read-only except when writing the mirror. Keeps backups somewhat safe against accidental recursive deletes.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB