LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 10-18-2004, 10:35 PM   #1
Stormproof
LQ Newbie
 
Registered: Aug 2002
Location: Slackware, KS
Distribution: Slackware
Posts: 12

Rep: Reputation: 0
automate database backup


I have a postgresql database that I would like to have backed up daily to a windows box. I do not want to use samba by any means.


I would like to use pg_dump to back up the database to a file. Once the file is created I would like it to be copied over to a windows box or linux machine.

I have been looking at "AT" and "CRON" to schedule pg_dump to backup the database

After the database is tranfered to a file on the linux side I would like it to be copied over to a windows box or another linux machine.

If a simple shell script would do the trick please advise





Please I need some help bad!
 
Old 10-19-2004, 03:19 AM   #2
maxut
Senior Member
 
Registered: May 2003
Location: istanbul
Distribution: debian - redhat - others
Posts: 1,188

Rep: Reputation: 50
Code:
#!/bin/bash
umount /mnt/2k 2>/dev/null 1>/dev/null
mount -t smbfs //winbox_name/share /mnt/2k/ -o username=administrator,password=pass
if [ ! -d /mnt/2k/backup ] ; then
echo " cannot erach the backup dir on network drive" >/root/script-logs
echo " directory might be deleted or cannot mount network drive" >>/root/yedek-scripts/script-logs
umount /mnt/2k 2>/dev/null 1>/dev/null
exit 0
fi
DATE=$(date +%d.%m.%Y-%H.%M)
echo "DATE:$DATE">>/root/script-logs
echo "-------------------------------------------------------------">>/root/script-logs
cp -R /path/to/backup/* /mnt/2k/backup 1>>/root/script-logs 2>>/root/script-logs 
umount /mnt/2k 1>>/root/script-logs 2>>/root/script-logs
this is very simple script. because it just copies files to windows share. u will probably want to delete older files keeping last 7 one or more and compress the files to save the disk space. if u want let me know pls

u can use cron to shedule the task. the following example will run /root/script file at 00:20 everyday:
#crontab -e
20 00 * * * /root/sctript.sh

good luck
 
  


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
SQLite database backup ddpicard Linux - Software 2 11-01-2004 06:54 PM
Automating a full database backup dominant Linux - Newbie 2 07-10-2004 07:59 AM
How would I automate this? onewhoknows Linux - Newbie 5 06-22-2004 04:49 AM
Need script to dump database, ftp file to backup server glock19 Linux - Networking 17 05-12-2003 05:56 PM
Had to restore database from backup - about 5 minutes lost jeremy LQ Suggestions & Feedback 0 01-21-2001 10:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:13 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
Open Source Consulting | Domain Registration