LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 02-24-2005, 07:04 PM   #1
myeire
LQ Newbie
 
Registered: Feb 2005
Location: Washington
Posts: 3

Rep: Reputation: 0
how to write a script to move files from one directory to another


I'm new to Linux and writing scripts, so I hope someone can help me. :-D

We are running rdiff-backup on our server every night under a cron job. It saves the incremental backups in /mnt/backup/rdiff-backup-data but with these increments it has filled up that partition (/dev/sdb2).

I want to have the increments saved on another partition that has much more room in /mnt/backup/var.

I've been searching for info on rdiff-backup to see if I can configure it to automatically save the increments in /mnt/backup/var, but no luck so far.

I'm wondering though if I can write another script that would move the increments from /mnt/backup over to /mnt/backup/var every night automatically?

Can that be done? Can anyone give me an idea how to do this if it's possible?

Thank you so much!
Dawn
 
Old 02-24-2005, 07:25 PM   #2
Poetics
Senior Member
 
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 1,181

Rep: Reputation: 49
Take a look at the "cron" function -- it can run a command at specific intervals.

Very easily it could run a "/dev/sdb2# mv * /mnt/backup/var/*" every night at midnight, or 3am, or whenever you decide
 
Old 02-24-2005, 07:28 PM   #3
odious1
Member
 
Registered: Jun 2003
Location: Virginia, USA
Distribution: Slackware
Posts: 252

Rep: Reputation: 30
sure it can be done. I am not familliar with rdiff-backup. you could use find and tar for example. i use a script running out of cron that uses find to create a backcup list based on the -mtime of the files. this file is then used by tar to bakup the files that have changes since my last full archive. this is one way but there are many more. look and dump and diff as well.

Tom
 
Old 02-24-2005, 08:10 PM   #4
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,346

Rep: Reputation: 552Reputation: 552Reputation: 552Reputation: 552Reputation: 552Reputation: 552
"I'm wondering though if I can write another script that would move the increments from /mnt/backup over to /mnt/backup/var every night automatically?"

Rather than writing a second script it would be more straightforward to add your extra commands to the end of the rdiff-backup script that cron runs.

------------------------------
Steve Stites
 
Old 02-24-2005, 08:11 PM   #5
myeire
LQ Newbie
 
Registered: Feb 2005
Location: Washington
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by Poetics
Take a look at the "cron" function -- it can run a command at specific intervals.

Very easily it could run a "/dev/sdb2# mv * /mnt/backup/var/*" every night at midnight, or 3am, or whenever you decide

We have cron jobs set up for daily, weekly and monthly.

With the daily one it's run every morning at 4am. The rdiff-backup is in that cron job to be ran at 4am, so can I set up a command to be run daily, but at a different time? Because I need to wait for the backup to be finished before I can move my files, so it should be ran at a later time like at 5am.

Can you have a daily cron job, but have it set to run at 2 different times?

Thanks,
Dawn
 
Old 02-24-2005, 08:11 PM   #6
susefan
Member
 
Registered: Feb 2005
Location: California, USA
Distribution: Novell SuSE
Posts: 39

Rep: Reputation: 15
Here's another idea ....

Without changing any scripts, and without any user training,
you could create a symbolic link from the full partition to
the partition with more space:

First, manually move anything you want to save from
/mnt/backup/rdiff-backup-data (I assume this is a directory)
to
/mnt/backup/var/rdiff-backup-data (A new directory that you have created)

then,
rm -rf /mnt/backup/rdiff-backup-data (to remove the old directory)

and,
ln -s /mnt/backup/var/rdiff-backup-data /mnt/backup/rdiff-backup-data


The result is that any references to /mnt/backup/rdiff-backup-data will be
automatically re-directed to /mnt/backup/var/rdiff-backup-data

Caveat: Try it out with unimportant data so that you understand
what is happening before you use it for stuff you can't afford to lose!

Hope this helps.
 
Old 02-24-2005, 08:12 PM   #7
myeire
LQ Newbie
 
Registered: Feb 2005
Location: Washington
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by jailbait
"I'm wondering though if I can write another script that would move the increments from /mnt/backup over to /mnt/backup/var every night automatically?"

Rather than writing a second script it would be more straightforward to add your extra commands to the end of the rdiff-backup script that cron runs.

------------------------------
Steve Stites

That would be great, but how do I write that script?

I'm so new to this, I'm just not sure what I need to write to make it work.

Thanks,
Dawn
 
Old 02-25-2005, 10:01 AM   #8
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,346

Rep: Reputation: 552Reputation: 552Reputation: 552Reputation: 552Reputation: 552Reputation: 552
"That would be great, but how do I write that script? "

Post the rdiff-backup script that cron runs and one of us can tell you what you need to add.

------------------------------------
Steve Stites
 
  


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
denied access to move files into /usr/src directory Larry O Linux - Newbie 4 01-17-2005 11:14 PM
Does anyone know how to move files to a particular directory using shell scripting RowanB Programming 3 11-11-2004 01:46 PM
Script to Move files jain_rajesh Linux - Newbie 1 10-15-2004 08:53 AM
write permissions for directory - not accidently move/deleted the directory linuxgamer Linux - Newbie 10 12-02-2003 03:04 AM
how to write a script to create a directory mgam Linux - Newbie 1 10-29-2003 12:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:09 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