LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to write a script to move files from one directory to another (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-write-a-script-to-move-files-from-one-directory-to-another-294519/)

myeire 02-24-2005 07:04 PM

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

Poetics 02-24-2005 07:25 PM

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

odious1 02-24-2005 07:28 PM

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

jailbait 02-24-2005 08:10 PM

"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

myeire 02-24-2005 08:11 PM

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

susefan 02-24-2005 08:11 PM

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.

myeire 02-24-2005 08:12 PM

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

jailbait 02-25-2005 10:01 AM

"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


All times are GMT -5. The time now is 05:11 PM.