TurnKey Linux Virtual Appliance Library

Non-TKLBAM Backup

Jason Adams's picture

Greetings,

I'm using Pg 9.1 on the most recent LAPP TK. This is deployed via OpenVZ on a Proxmox server.

This will be given, along with other equipment, to a client. What I'm really curious of is ways of backing up the Pg database I can suggest/offer them, aside from TKLBAM — I don't want to use this because it needs to work on a closed network. The trick is, I'm fairly new to Linux and still associating myself it. I'm now trying to trudge into the area of creating local/remote backups on Linux systems, and especially how to do it in a scheduled form.

I could write a console app that connects to a machine elsewhere and handles the backups... but I feel like I'm re-inventing the wheel. Any and all suggestions are appreciated.

Thanks! Loving Turnkey! :)

Jeremy's picture

I don't know PostgreSQL

But I'd imagine that there is a command to dump the database. You could then rsync or sftp the dump to wherever you wish to store it. 

There may be something already, but creating a script yourself should be fairly trivial. Create a basic script to do the above 2 steps and run it from cron (setting whatever schedule you want - hourly, daily, etc). I also suggest that you set it to log somewhere too. That should also be pretty easy, when you set up the cron job, send the output to a file (instead of the screen).

Jason Adams's picture

Great advice!

Thanks, man! You're correct in that it has a pg_dump function, and I'm familiar with how to properly dump and store the db. Unfortunately I have no experience with writing Linux scripts, but I'm looking into tutorials and the like now.

If you have any suggestions on good resources, please let me know.

Jeremy's picture

Linux bash scripts are simply lines of commands

So basically if you take note of commands you use to achieve your ends, put then in a plain text file (NOT a Windows text file though...!) Put "#!/bin/bash" on the first line (so Linux knows it's a script). So it'd look something like this:

#!/bin/bash
<pg-dump command>
<rsync/ftp command to copy to desired backup location>
#end

Then make it executable:

chmod +x <filename>

And test it:

./path/to/filename

When you set it up to run as a cron job, just remember that you will need to put the full path to the script.

Google is a great resource for working out the details of bash scripts (and most things Linux). For scripting use keywords like "bash", "linux", debian", "commandline" etc.

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <strike> <caption>

More information about formatting options

Leave this field empty. It's part of a security mechanism.
(Dear spammers: moderators are notified of all new posts. Spam is deleted immediately)