LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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: 68

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
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,141
Blog Entries: 6

Rep: Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828
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
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,141
Blog Entries: 6

Rep: Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828
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



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 02:04 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