Problems backing up a folder


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problems backing up a folder
# 1  
Old 03-17-2012
Problems backing up a folder

So I play on a minecraft server that keeps crashing, then rolling back, losing about 30 minutes of data. I don't own the server I'm just writing it for him. So I'm trying to have the script make a back up of the server every 5 minutes as long as it is bigger than the back up, since as more things are done the folder size increases and when it rolls back it decreases.
Code:
cd path
worldsize1=[du -s world]
worldsize2=[du -s world]
while [[$worldsize1 -lt $worldsize2 || $worldsize1 -eq $worldsize2]];do
    worldsize1=[du -s world]
    while [[$SECONDS % 300 -ne 0]];do
    done
    mkdir tempworld
    cp world /tempworld/
    cd path/tempworld
    mv world copiedworld
    cd path
    mv tempworld/copiedworld copiedworld
    rmdir tempworld
    worldsize2=[du -s world]
done

The variables path and world are the only things that will be substituted. I'm quite new to this, and I'm coding this for Solaris while running ubuntu.
# 2  
Old 03-17-2012
Corrected a few things:

Code:
path='/path/to/dir'
cd "$path"
worldsize1=$( du -s world )
worldsize2=$( du -s world )
while [ $worldsize1 -lt $worldsize2 ] || [ $worldsize1 -eq $worldsize2 ];do
    worldsize1=$( du -s world )
    # no need for a loop to wait 5 mins
    # you would be wasting CPU cycle in that way
    sleep 300
    mkdir tempworld
    cp world /tempworld/
    cd path/tempworld
    mv world copiedworld
    cd path
    mv tempworld/copiedworld copiedworld
    rmdir tempworld
    worldsize2=$( du -s world )
done

# 3  
Old 03-17-2012
Thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Backing up an entire HD

Are there any recommended methods for Backing up an entire HD? I want to backup my data. I do not care about the OS file. I just want my work, movies, and music. I have about 600 GB of work, movies, and music so a bit worried about fragmentation if I just copy and paste. (1 Reply)
Discussion started by: cokedude
1 Replies

2. Solaris

Backing up root disks

Hi ! I wonder if in solaris 10 there is a utility similar to ignite in HP-UX that backup entire file systems (/, /usr, /var, /tmp, /home). I have to backup only the root disk of a server, but ufsdump seem to be backing up individual file systems....only, am I correct? (1 Reply)
Discussion started by: fretagi
1 Replies

3. Shell Programming and Scripting

Need help in backing up of databases.

Hi Everyone, I am new to DBA stuff. I wonder if anyone can help me. Task is that, I have 10 databases and need to take backups of all the databases using data pump in Unix/Linux, compress them using gzip and use cron to schedule the job twice a day. Appreciate if anyone can help me in... (1 Reply)
Discussion started by: sreepriya0987
1 Replies

4. Solaris

Backing up using fssnap and ufsdump

Hi all! Here's my situation: I need to backup a running system before I can bring it down I've tried performing a ufsdump while it's in multi-user mode but my ufsdump fails because there is too much activity on the system. So I read that I could use fssnap to create a snapshot of (in my... (3 Replies)
Discussion started by: Keepcase
3 Replies

5. AIX

what am i backing up

we are running aix on are server. we would like to start doing online backups, but the software company that we use is not beeing much help on what files we are backing up. is there a command that will tell me what files that we are backing up. they offer a service that would back it up for use,... (3 Replies)
Discussion started by: shane.hankins
3 Replies

6. Solaris

Backing up the system

Hello Mentors, Before anything else I would like to thanks to all expert here especially Pressy as he guided me to recover our server from disk failure. I posted a lot of question from these forum site concerning on how to recover our server and luckly you guys help me. Our server is now up and... (6 Replies)
Discussion started by: eykyn17
6 Replies

7. UNIX for Dummies Questions & Answers

backing up the vtoc

Can you backup the vtoc, then restore it if you somehow mess it up? This is solaris 9, x86. (1 Reply)
Discussion started by: BG_JrAdmin
1 Replies

8. UNIX for Dummies Questions & Answers

Best practises for backing up

Hi, I'm about to start a regular backup schedule for my Linux system. I need some pointers if I may :) The system is *mainly* used as a personal home computer (it's actually a laptop running SuSE 9.2) although I do host some client material from it being a PHP developer. I know that in... (2 Replies)
Discussion started by: d11wtq
2 Replies

9. UNIX for Dummies Questions & Answers

Backing Up Directories

Hi Guys, I'm writing a shell script that presents the user with various options, they select one (numbered 1-9) and it then excecutes the correct code. No problem, but I'm having slight difficulty with one option. The user can select to backup all the files in the current directory to another... (2 Replies)
Discussion started by: indigoecho
2 Replies

10. UNIX for Dummies Questions & Answers

backing up

Ok I'm trying to backup a HD using ufsdump but no matter what I do it rewinds the tape after the dump. Now the tape isn't full (only 285mb) and I still have 6 more partitions I want to put on this tape. How can I stop the tape from rewinding because I can't think of anything. Also is there any... (4 Replies)
Discussion started by: merlin
4 Replies
Login or Register to Ask a Question