LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 07-13-2006, 09:46 AM   #1
gtrawoger
Member
 
Registered: Dec 2005
Location: TO, Ontario, Canada
Distribution: Ubuntu 14.04, CentOS 6.5
Posts: 37

Rep: Reputation: 17
Need backup script.


Hi there,

I am fairly new in linux and got a couple questions regarding scripting. I don't know much about it at all.

What I need it to do is run a cron job on the machine every night around 8:00 PM.

This is what I'd like it to do:

- take two files from a commonly accessible area: x.file + y.file

- archive and compress the two: x.file + y.file ==> x+y.tar.gz

- name the new file with a date in it: x+y_130706.tar.gz

- ftp the file to a remote location: ftp://remote.location.com/x+y_130706.tar.gz

I just don't know how to write the script for that. I can't imagine it being too difficult. And I wouldn't mind learning to script some things myself.

I am running Fedora Core 5 on the system, and was wondering what cron program I could use as well.

Thanks.
 
Old 07-13-2006, 01:10 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,953
Blog Entries: 54

Rep: Reputation: 2733Reputation: 2733Reputation: 2733Reputation: 2733Reputation: 2733Reputation: 2733Reputation: 2733Reputation: 2733Reputation: 2733Reputation: 2733Reputation: 2733
What I need it to do is run a cron job on the machine every night around 8:00 PM.
If root backs up files:
Code:
echo "* 20 * * * root /root/bin/backup.sh" >> /etc/crontab
else modify for your personal "crontab -e"


No checks, no testing, no optimisation, no cleaning up and no ftp (but scp):
Code:
#!/bin/sh
files=( /tmp/x.file "/home/gtrawoger/some dir/y.file" )
arch_d=/tmp; arch_t=$(date '+%Y%m%d')
for n in $(seq 0 ${#files[@]}); do fn="${fn} $(basename "${files[$n]}" .file)"; done
arch_n=$(eval echo fn=${fn:1}|tr " " "+"); t="$arch_d/${arch_n}_${arch_t}.tar.gz"
tar -czf "$t" ${files[@]} && scp "$t" user@host:/some/dir && rm -f "$t"
exit 0
* using DDMMYYYY IMHO ain't good for sorting purposes: use YYYYMMDD.


And I wouldn't mind learning to script some things myself.
Search LQ for "ABS" or "Advanced Bash Scripting" guide.
 
Old 07-17-2006, 07:31 AM   #3
gtrawoger
Member
 
Registered: Dec 2005
Location: TO, Ontario, Canada
Distribution: Ubuntu 14.04, CentOS 6.5
Posts: 37

Original Poster
Rep: Reputation: 17
unSpawn,

thanks. I will try this out.
 
  


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
Backup Script Help Canni Programming 8 06-15-2006 10:19 AM
backup script nitaish Linux - General 1 04-22-2005 11:31 AM
backup script wiltzius Linux - Software 8 03-23-2005 05:12 PM
Need a backup script enygma Linux - General 5 11-04-2004 03:49 PM
help with backup script dennis_89 Linux - Networking 2 06-29-2004 09:47 AM


All times are GMT -5. The time now is 01:52 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration