From: Mitchell Laks <mlaks@verizon.net>
To: pgsql-admin@postgresql.org
Subject: how to make a trigger to copy files.
Date: Sun, 23 Jan 2005 13:47:53 -0500
Message-ID: <200501231347.53304.mlaks@verizon.net> (raw)
Hi.
I have a postgresql database backed application. As soon as the application
stores a file on my server, it creates a entry in a table LOCATION_TABLE
which stores the file location in the table in my postgresql database (eg. in
LOCATION_TABLE in database MASTER).
I have read about triggers and wondered if I could use them.
I would like my server to immediately "scp" the file to another machine, as
soon as the application updates the table with the new entry. (right now i
have a cron job that runs a perl script that queries the database for new
entries every 5 minutes, but i would like to have the new file (whose
location is stored in the new LOCATION_TABLE entry) to be "scp"'d
immediately, not after 5 minutes. Also a trigger seems more elegant...
But when i look for sample triggers on the web they seem to only do things
internal to the database (change field entries etc, check them for business
logic rules etc).
I am running postgresql 7.4.6 on debian sarge. I am most familiar with perl.
Could i create a database trigger to run a script like
system("scp $filename $destination");
where $filename is extracted from the entry just made into the database, and
$destination is my other pc?
Thanks,
Mitchell Laks
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: mlaks@verizon.net
Subject: Re: how to make a trigger to copy files.
In-Reply-To: <200501231347.53304.mlaks@verizon.net>
References: <200501231347.53304.mlaks@verizon.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox