LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-24-2012, 04:04 AM   #1
miros84
Member
 
Registered: Aug 2009
Location: Spain
Distribution: Debian stable, squeeze
Posts: 501

Rep: Reputation: 31
Copy a folder from NAS to other HDD every day


Hello,

I use Debian Squeezy.
I need to copy a folder from NAS to other HDD every Monday and Fryday.
is thre some program that I can use for that?
 
Old 12-24-2012, 11:45 AM   #2
memilanuk
Member
 
Registered: Sep 2010
Location: Washington state, USA
Distribution: Ubuntu among others
Posts: 67

Rep: Reputation: 2
Work out a script that does what you want, and then run it via cron at the appointed times?
 
Old 12-24-2012, 08:09 PM   #3
teckk
Senior Member
 
Registered: Oct 2004
Distribution: FreeBSD Arch
Posts: 3,016

Rep: Reputation: 836Reputation: 836Reputation: 836Reputation: 836Reputation: 836Reputation: 836Reputation: 836
An example mounting the NAS with samba, passwordless sudo. Use NFS, FTP, SCP, whatever you want. Use cifs instead of smbfs if you want. If the NAS is already mounted then skip that part. Save the script as something.sh. Then make something.sh executable.

Code:
#!/bin/bash

sudo mount -t smbfs //NAS/share /path/to/HDD/share &&
sleep 5 &&
cp -nR "/path/to/HDD/share" "/path/to/where/you/want/it/" &&
sleep 5 &&
sudo umount /path/to/HDD/share
Use crontab to launch the script when you want.
Here is how crontab works.
http://www.adminschoice.com/crontab-quick-reference
http://crontab.org/
http://www.thegeekstuff.com/2009/06/...ntab-examples/

There are also frontends for crontab like gnome-schedule
 
Old 12-25-2012, 02:11 AM   #4
miros84
Member
 
Registered: Aug 2009
Location: Spain
Distribution: Debian stable, squeeze
Posts: 501

Original Poster
Rep: Reputation: 31
Thank you for the examples. My NAS has password. SO I need to add the password, right?
What about sleep 5? What that does?
 
Old 12-25-2012, 08:38 AM   #5
teckk
Senior Member
 
Registered: Oct 2004
Distribution: FreeBSD Arch
Posts: 3,016

Rep: Reputation: 836Reputation: 836Reputation: 836Reputation: 836Reputation: 836Reputation: 836Reputation: 836
Quote:
My NAS has password. SO I need to add the password, right?
Add a way to enter password. This was a simple script example, you could make it more elegant. Xterm will launch and wait for a password.
Code:
#!/bin/bash

xterm -e sudo mount -t smbfs //NAS/share /path/to/HDD/share &&
sleep 5 &&
cp -nR "/path/to/HDD/share" "/path/to/where/you/want/it/" &&
sleep 5 &&
xterm -e sudo umount /path/to/HDD/share
Quote:
What about sleep 5?
Sleep for 5 seconds, give mount and cp time to finish.

http://www.commandlinefu.com/command.../sort-by-votes
http://www.freeos.com/guides/lsst/
http://tldp.org/LDP/abs/html/

Last edited by teckk; 12-25-2012 at 08:39 AM.
 
  


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
[SOLVED] How do I copy root the file system of an internal hdd to a usb hdd completelinuxnube Slackware 8 08-06-2012 02:22 PM
[SOLVED] Using terminal command -Find files in a folder and copy them to a different folder j-jock Linux - General 4 11-28-2011 02:20 AM
Scripts to list folder contents and copy images from folder and subfolders brunces Linux - Newbie 6 11-03-2011 01:23 PM
automatically backup folder on Free NAS computer to another Free NAS computer tom treadway Linux - Newbie 1 01-26-2011 07:28 PM
want to copy an inode folder from acdrom to a home directory (folder). nhbob Linux - Newbie 8 12-20-2009 11:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:49 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
Open Source Consulting | Domain Registration