LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 09-25-2011, 07:43 AM   #1
snooze1
Member
 
Registered: Sep 2011
Posts: 34

Rep: Reputation: Disabled
Attempting to make a .sh backup script.


Hello,

On my server I have three directories that I need to backup, the Database directory, the game files directory and another directory.

With the gamefiles directory it contains the main directory, and then multiple sub directories inside there, then with each sub directory has more subdirectories etc.

Currently I am using the following script
Code:
echo "TCAdmin Backup Starting"
sleep 5
#TCAGAME (all gameserver files)
cd /home/
tar -zcvf tcagame.tar.gz tcagame
mv tcagame.tar.gz /home/backups
#TCADMIN Database (for SQLi)
cd /home/tcadmin/
tar -zcvf database.tar.gz Database
mv database.tar.gz /home/backups
#MINECRAFT BACKUP (for mod purposes)
cd /home/tcadmin/tcafiles/games/
tar -zcvf minecraft.tar.gz minecraft
mv minecraft.tar.gz /home/backups
echo "TCAdmin Backup Completed"
All it's doing is backing up the folders, and I'm unsure in how to get the WHOLE directory compressed, including sub folders, files, etc.

Can anyone tell me where I'm going wrong, this is my first .sh script.
 
Old 09-25-2011, 08:26 AM   #2
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
tar -cpvzf backupfile.tar.gz topdirectory

would normally do the trick: tar is recursive by default.
The p is needed to keep permissions.
Does the user running tar have permission to archive the files?
Since you are running verbose, did your read the messages?
http://www.geekvenue.net/chucktips/j...279/index_html
 
Old 09-25-2011, 08:27 AM   #3
snooze1
Member
 
Registered: Sep 2011
Posts: 34

Original Poster
Rep: Reputation: Disabled
I'm running it as root, so I would believe so.
 
Old 09-25-2011, 08:28 AM   #4
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 840

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Do you get any error messages while running the script?
 
Old 09-25-2011, 09:28 AM   #5
snooze1
Member
 
Registered: Sep 2011
Posts: 34

Original Poster
Rep: Reputation: Disabled
Running the "tar -cpvzf tcagame.tar.gz tcagame" still did not backup the folders within the directories content.
 
Old 09-25-2011, 09:40 AM   #6
jv2112
Member
 
Registered: Jan 2009
Location: New England
Distribution: Arch Linux
Posts: 719

Rep: Reputation: 103Reputation: 103
Lightbulb

I would consider just doing incremental back ups and create the tar ball where you want to store it

I would also use Bzip2 as the feedback I have heard is that the compression is better than gzip......



Just a thought.................

_______________________________________________________

if [[ -e /path/to/name.tar.gz ]]; then
tar -cpvjfu /path/to/destination/name.tar.bz Data
else
tar -cpvjf /path/to/destination/name.tar.bz Data
fi

..... add in notifications echo , espeak , zenity statements as desired..........
_____________________________________________________

http://unixhelp.ed.ac.uk/CGI/man-cgi?tar --> Man Page
_______________________________________________________
 
Old 09-25-2011, 09:46 AM   #7
snooze1
Member
 
Registered: Sep 2011
Posts: 34

Original Poster
Rep: Reputation: Disabled
I will use any compression format that will decompile on Linux. I have a backup VPS (for now a VPS, anyway) where I store the backups, and with the example above it looks as if you're only looking to compress one file? I'm looking to do it to a whole directory.

Last edited by snooze1; 09-25-2011 at 09:49 AM.
 
Old 09-25-2011, 02:30 PM   #8
jv2112
Member
 
Registered: Jan 2009
Location: New England
Distribution: Arch Linux
Posts: 719

Rep: Reputation: 103Reputation: 103
"Data" in my post is whatever you want it to be. If you set to a directory it will recursively create a compressed tar ball for everything underneath it. bzip2 can compress & decompress in Linux by the use of tar and other programs as well.
 
Old 09-25-2011, 04:23 PM   #9
silent
LQ Newbie
 
Registered: Sep 2011
Location: The road from nowhere to elsewhere
Distribution: Gentoo Linux
Posts: 14

Rep: Reputation: 3
Tar should recurse into subdirectories and maybe you should just try the statements from your terminal then proceed to the script.
Compression with gzip would be faster but bzip2 compresses better with indeed taking more time and cpu work.
 
Old 09-26-2011, 03:58 AM   #10
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
You are running tar in verbose mode.
This means it printed out a lot of stuff for you to read.
Did you read it? What did it say? (hint: copy and paste.)
Did you see any error messages?

If you don't answer questions we cannot help you.
 
  


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] Attempting to make WMP54Gv4 connect dfiggy Linux - Wireless Networking 8 09-13-2010 06:51 PM
HOW TO MAKE backup script LINUX CentOS5 copy data to another machine ytd Linux - Newbie 8 09-30-2009 02:54 PM
Make a desktop icon for python backup script OS X mannclay Programming 0 03-23-2009 10:46 AM
Error when attempting backup with File Backup lglrgl Linux - Software 0 08-03-2006 11:38 AM
attempting to make a bootable cd with k3b mnchur Linux - Software 1 01-26-2005 04:55 PM


All times are GMT -5. The time now is 12:20 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration