LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-07-2015, 07:13 AM   #1
JackDinn
Member
 
Registered: May 2015
Posts: 211

Rep: Reputation: Disabled
Question how do i automate backup of files on NAS ?


HI,

It would seem a very simple thing but na (nothing is simple on linux :-/)

Im trying to make a cronjob to copy a file from my NAS to local but although the file manager can access the NAS i cant figure out how to read/write with the terminal ?

the NAS is smb://192.168.1.1/volume(sda1)/

tried :-

greg@greg-W7XXC ~ $ cd smb://192.168.1.1/volume(sda1)/
bash: syntax error near unexpected token `('

greg@greg-W7XXC ~ $ cd /$XDG_RUNTIME_DIR/gvfs
greg@greg-W7XXC //run/user/1000/gvfs $ ls
smb-share:server=192.168.1.1,share=volume(sda1)

this gets me to the NAS but i cant get to the volume ?

thx.

Last edited by JackDinn; 06-07-2015 at 07:15 AM.
 
Old 06-07-2015, 07:52 AM   #2
asimba
Member
 
Registered: Mar 2005
Location: 127.0.0.0
Distribution: Red Hat / Fedora
Posts: 355

Rep: Reputation: 42
try using single quotes in url

cd 'smb://192.168.1.1/volume(sda1)/'
 
Old 06-07-2015, 07:53 AM   #3
JackDinn
Member
 
Registered: May 2015
Posts: 211

Original Poster
Rep: Reputation: Disabled
greg@greg-W7XXC ~ $ cd 'smb://192.168.1.1/volume(sda1)/'
bash: cd: smb://192.168.1.1/volume(sda1)/: No such file or directory

definitely accessible though:-
Click image for larger version

Name:	2015 06 07 12:54:46.png
Views:	16
Size:	70.3 KB
ID:	18629

Last edited by JackDinn; 06-07-2015 at 07:57 AM.
 
Old 06-07-2015, 08:19 AM   #4
antiX-Dave
LQ Newbie
 
Registered: Dec 2013
Distribution: antiX
Posts: 22

Rep: Reputation: Disabled
Put the smb mount in your fstab so it mounts to a directory with the same name which you will specify. Then you can mount the share via mount /mount/point/specified , cd to the mount point cd /mount/point/specified, copy / rsync the files cp /mount/point/specified/file /home/myuser/file, then unmount when done umount /mount/point/specified.


Alot is described for you here

https://wiki.archlinux.org/index.php/Samba
 
1 members found this post helpful.
Old 06-07-2015, 02:55 PM   #5
asimba
Member
 
Registered: Mar 2005
Location: 127.0.0.0
Distribution: Red Hat / Fedora
Posts: 355

Rep: Reputation: 42
Quote:
Originally Posted by JackDinn View Post
greg@greg-W7XXC ~ $ cd 'smb://192.168.1.1/volume(sda1)/'
bash: cd: smb://192.168.1.1/volume(sda1)/: No such file or directory

definitely accessible though:-
Attachment 18629
Try escaping "("

cd 'smb://192.168.1.1/volume\(sda1\)/'

Also see if this article helps you - its old article (2007) hence may not at all be helpful with existing version of samba.
 
Old 06-07-2015, 04:32 PM   #6
JackDinn
Member
 
Registered: May 2015
Posts: 211

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by asimba View Post
Try escaping "("

cd 'smb://192.168.1.1/volume\(sda1\)/'

Also see if this article helps you - its old article (2007) hence may not at all be helpful with existing version of samba.
greg@greg-W7XXC ~ $ cd 'smb://192.168.1.1/volume\(sda1\)/'
bash: cd: smb://192.168.1.1/volume\(sda1\)/: No such file or directory


@antiX-Dave

I have been reading & testing with your suggestion and its taken a little while but im almost there now the last thing i need to figure is how to have cron run the mount command as root when its in the bash script ?

Code:
greg@greg-W76OC ~ $ sudo mount ~/NAS
greg@greg-W76OC ~ $ cd NAS
greg@greg-W76OC ~/NAS $ ls
greg.kmy  Greg.QIF  JDs Auto Speed Tester.desktop  Quick Notes.txt  Untitled Folder
greg@greg-W76OC ~/NAS $
 
Old 06-07-2015, 05:01 PM   #7
joec@home
Member
 
Registered: Sep 2009
Location: Galveston Tx
Posts: 290

Rep: Reputation: 70
Depends on the distro, though I think the older method is slowly being phased out.

depriciated
smbmount "\\\\12.34.56.78\\c$" -U guest -c 'mount /home/windows -u 100 -g 100'

newer
mount -t cifs -o username=_user_name_,password=_password_ //_ip_address_/_share_name_ /_mount_point_
 
Old 06-07-2015, 10:49 PM   #8
antiX-Dave
LQ Newbie
 
Registered: Dec 2013
Distribution: antiX
Posts: 22

Rep: Reputation: Disabled
Well there are probably a couple of ways to get around the root mount issue. Perhaps the most guaranteed one is to run it in root crontab, but I do not think that is such a great idea. Another is to mount as a user with fuse / gvfs /etc. However I think I would add the mount command to your sudoers file for your user being a specific as possible on the mount command.

Last edited by antiX-Dave; 06-07-2015 at 10:51 PM.
 
Old 06-08-2015, 02:30 AM   #9
asimba
Member
 
Registered: Mar 2005
Location: 127.0.0.0
Distribution: Red Hat / Fedora
Posts: 355

Rep: Reputation: 42
Could Automount be a solution
 
Old 06-08-2015, 02:48 AM   #10
JackDinn
Member
 
Registered: May 2015
Posts: 211

Original Poster
Rep: Reputation: Disabled
Quote:
your sudoers file
you lost me ?

Quote:
Could Automount be a solution
please elaborate.

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

Dam, all i want to do is copy a file , after all the problems iv had trying to replace windows with linux (this is just the latest in a long line) im starting to think its all by design to keep linux out of the reach of laymen :P

Thx though guys.
 
Old 06-08-2015, 04:37 AM   #11
JeremyBoden
Member
 
Registered: Nov 2011
Posts: 938

Rep: Reputation: 174Reputation: 174
Quote:
non-superuser mounts.
Normally, only the superuser can mount filesystems. However, when fstab contains the user option on a line, any‐
body can mount the corresponding filesystem.
So you can have automounting, without sudo or root.
 
Old 06-08-2015, 04:40 AM   #12
asimba
Member
 
Registered: Mar 2005
Location: 127.0.0.0
Distribution: Red Hat / Fedora
Posts: 355

Rep: Reputation: 42
Quote:
Originally Posted by JackDinn View Post
you lost me ?



please elaborate.

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

Dam, all i want to do is copy a file , after all the problems iv had trying to replace windows with linux (this is just the latest in a long line) im starting to think its all by design to keep linux out of the reach of laymen :P

Thx though guys.
http://www.linuxfocus.org/Turkce/Jan...141.meta.shtml

This is old article but has good explanation to get you started with this.


For technical stuff : https://access.redhat.com/documentat...ig-autofs.html

At first it may seem different from mouse operations - but if you look close - its something you could learn quick and have it work for you.
 
Old 06-08-2015, 05:22 AM   #13
JackDinn
Member
 
Registered: May 2015
Posts: 211

Original Poster
Rep: Reputation: Disabled
Thank you all, there does seem to be a good few ways of doing this but i have just figured one of them, so im happy for now

fstab added:-
//192.168.1.1/volume(sda1) /home/greg/NAS cifs user,password=xxxx

then:-
greg@greg-W7XXC ~ $ mount ~/NAS
greg@greg-W7XXC ~ $ ls NAS
greg.kmy Greg.QIF JDs Auto Speed Tester.desktop Quick Notes.txt Untitled Folder
greg@greg-W7XXC ~ $


Many thx all!
 
2 members found this post helpful.
Old 06-13-2015, 05:11 AM   #14
JackDinn
Member
 
Registered: May 2015
Posts: 211

Original Poster
Rep: Reputation: Disabled
Hi, I am re-visiting this as i want to make a credentials file rather than have my PW in the fstab file but i cant figure it

why cant i do this (the links above say i can):-

Code:
//192.168.1.1/volume(sda1) /home/greg/NAS cifs username=greg,password=password
or this (not sure which it should be anyhow)
Code:
//192.168.1.1/volume(sda1) /home/greg/NAS cifs username=root,password=password
the only way iv got this part to work is like this :-

Code:
//192.168.1.1/volume(sda1) /home/greg/NAS cifs user,password=password
but i cant make a credentials file for that (user=?)
 
Old 06-17-2015, 11:46 AM   #15
joec@home
Member
 
Registered: Sep 2009
Location: Galveston Tx
Posts: 290

Rep: Reputation: 70
Sounds like you are getting your directive names confused with your variables names. Just as example, unrelated to this but still applies make two files. One for holding data, the other for processing data.

File1
Code:
x="1"
y="2"
File2
Code:
bash File1
echo $x $y
To code such a thing is a bit more tricky since your looking at referencing multiple users and passwords, something more along the lines of:

users_file
Code:
user1 password_for_user1
user2 password_for_user2
user3 password_for_user3
Connection
Code:
Echo "Select User"
read selected_user
//192.168.1.1/volume(sda1) /home/greg/NAS cifs username="$selected_user",password="$(grep $selected_user /path/to/
users_file |awk '{print $2}')"
Add what ever traps bells and whistles to report failures if the user does not exist or the password does not match ect.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Automate backup of Google Apps accounts ifeatu Programming 3 02-03-2010 02:10 PM
Buffalo NAS - how do we get files on NAS syncing with Windows Sync? bykerbob Linux - Newbie 0 10-21-2008 09:59 PM
LXer: Speaking Unix, Part 6: Automate, automate, automate! LXer Syndicated Linux News 0 01-04-2007 10:54 AM
cannot automate rsync backup jahjr Linux - Server 6 12-21-2006 05:54 AM
automate database backup Stormproof Linux - Networking 1 10-19-2004 04:19 AM


All times are GMT -5. The time now is 08:26 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration