Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Samba share on my NAS drive mounter as follows:

mount -t smbfs -o username=backup,password=backups_password //sharebox/SVNBackup /mnt/SVNBackup

I am then trying to run:

sudo svnadmin dump /usr/local/svn/repos/testrepo > /mnt/SVNBackup/test1.svn

but I get:

bash: /mnt/SVNBackup/test1.svn: Permission Denied

The backup location is setup to accept access only from the user "backup" (who doesn't exist on the local system)

How do I go about solving this problem? Thanks

share|improve this question
I found that if I do sudo /bin/bash and then run the command (without sudo) it works. Does this help with a solution? I need to script it eventually so that's why this isn't an acceptable solution that I have found. – Hamid Oct 25 '10 at 15:50

sudo command > outputfile doesn't do what you think. Specifically, the outputfile is opened with your permissions, not the sudo user's (in this case, root). That's why it works when you become root and run the command - because then the redirect does run as root, who can write to /mnt/SVNBackup . It is necessary and sensible that sudo behaves this way.

Find some way of running the whole command as root; put it in root's cron, or write a one-line shell script and invoke that with sudo, or find another fix that works for you. In the limiting (and slightly stupid) case,

sudo svnadmin dump /usr/local/svn/repos/testrepo | sudo tee /mnt/SVNBackup/test1.svn

should produce the output both on stdout and in the file /mnt/SVNBackup/test1.svn . Bizarre though it may seem, if you really don't want the output, the simplest way may be to do

sudo svnadmin dump /usr/local/svn/repos/testrepo | sudo tee /mnt/SVNBackup/test1.svn > /dev/null

If the original svnadmin command produces stuff on STDERR and you want that in the log file too, try

sudo svnadmin dump /usr/local/svn/repos/testrepo 2>&1 | sudo tee /mnt/SVNBackup/test1.svn > /dev/null

Note that 2>&1 is a bash forumlation, if your shell is a csh-variant, or something different yet, you'll need to find something appropriate.

share|improve this answer
Thank you. This seems like the answer I needed, and I suspected that the root after the pipe was the problem but couldn't see an immediate fix since there simply was no "command" there to run as root but simply a path. as for "tee" is there an alternative that I can use and not have it throw the output at stdout? this is a lot of "junk" that I could do without in the log (not that I know exactly what format all this "junk" is going to take.) Essentially, my goal is to have the script run nightly by whichever user is necessary. Does Ubuntu server give me access to roots cron? – Hamid Oct 26 '10 at 7:10
I've amended the answer above accordingly. – MadHatter Oct 26 '10 at 8:03
As for access to root's crontab, that's not an Ubuntu question; unless arrangements have been made, normal users have access only to their own crontabs under Unix. Depending on how your system is set up, you may have access to root privilege via the /bin/su command and the root password, or via the sudo command. Ask your sysadmin for more details. – MadHatter Oct 26 '10 at 8:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.