LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-13-2018, 09:11 AM   #1
Superspeed500
Member
 
Registered: Oct 2017
Distribution: Fedora, Ubuntu, Rocky Linux, Debian
Posts: 46

Rep: Reputation: Disabled
Question Prevent server software from writing to /mnt when SMB share is not mounted on Ubuntu Server


I have a Ubuntu 18.04 server that uses a combination of rsync and duplicity for backup purpose. Both are configured to sync the files to a SMB server with shell scripts run in a cronjob for the root user. The SMB server is mounted using data from /etc/fstab as /mnt/backup.

My SMB share, hosted on a qnap TS-431Xeu NAS, do sometimes go offline for updates or configuration updates. That causes rsync and duplicty to sync their files to the local disk under /mnt/backup resulting in serious problems with the server disk space.

So my question is: Is there a way to prevent all programs (or just rsync and duplicity) to write their files if the SMB share is not mounted at /mnt?

My fstab SMB entries:
Code:
# Connect SMB share for backup purpose
//<ip address>/Sikkerhetskopi\040(Linux)/ /mnt/backup  cifs    credentials=<removed for security>,iocharset=utf8 0 0
//<ip address>/Multimedia/Mediaserver/ /mnt/mediaserver cifs credentials=<removed for security>,iocharset=utf8 0 0
Thanks in advance
 
Old 09-13-2018, 09:34 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 448Reputation: 448Reputation: 448Reputation: 448Reputation: 448
There's a command "mountpoint" that will tell you if something is mounted or not. In your backup script, you can add a check in the beginning of the script. Something like this:

Code:
if ! mountpoint -q /mnt/backup ; then 
  echo "/mnt/backup is not mounted - backup skipped!"
  exit
fi
rsync ...
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I mount a NFS share that have a SMB share mounted? perezyanez Linux - Networking 2 09-26-2008 09:03 AM
Apache writing to smb share on windows box? darthfoolish Linux - Server 2 08-14-2008 04:51 PM
directory permissions on mounted smb share in fstab glok_twen Linux - Server 2 02-18-2008 06:13 AM
Linux server for torrent, newsleecher, Itunes server and smb share. Freemen Linux - Newbie 3 11-26-2007 04:14 AM
Accessing a mounted smb share hangs haddad Linux - Wireless Networking 0 07-24-2004 05:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration