0

Ruby on Rails アプリケーションで PostgreSQL データベースを使用しています。次のコマンドを使用して、データベースのバックアップを手動で作成します。

pg_dumpall -c --inserts -f ~/Desktop/pgdumpall_`date +%Y%m%d_%H%M%S`.sql

このコマンドを数時間ごとに実行するようにスケジュールしたいと思います。

私はここを含め、多くのウェブ検索を行いました。PgAgent に関するドキュメントを見つけました。私は現在、PgAgent の維持に使用できるとドキュメントに記載されている最新バージョンの PgAdmin を使用しています。

最新バージョンをダウンロードしました。README のインストール手順を読んだとき、不足しているアプリケーションをダウンロード/インストールする以外に何をすべきかがよくわかりませんでした。以下にそれらを含めました。

This document describes the compilation of pgAgent, a job scheduler for 
PostgreSQL.

pgAgent is managed using pgAdmin (http://www.pgadmin.org). The pgAdmin 
documentation contains details of the setup and use of pgAgent with your
PostgreSQL system. The latest build of the documentation can be found at
http://www.pgadmin.org/docs/dev/pgagent.html.

Building pgAgent
----------------

You will need:

- A C/C++ compiler, such as GCC or Microsoft Visual C++ on Windows.
- CMake 2.6 (from www.cmake.org)
- A wxWidgets 2.8.x installation, configured per the requirements for
  pgAdmin:
  http://git.postgresql.org/gitweb/?p=pgadmin3.git;a=blob_plain;f=INSTALL;hb=HEAD
- A PostgreSQL 8.3 or higher installation

1) Unpack the pgAgent source code
2) Create a build directory in which the code will be built.
3) Run ccmake from the build directory (on Windows, use the CMake graphical
   interface). By default, ccmake will generate Unix Makefiles - consult the 
   documentation if you wish to generate other types of output:

$ ccmake /path/to/pgagent

4) If required, press 'c' to generate a default configuration:

CMAKE_BUILD_TYPE                 Release
CMAKE_INSTALL_PREFIX             /usr/local
CMAKE_OSX_ARCHITECTURES          ppc;i386
CMAKE_OSX_SYSROOT                /Developer/SDKs/MacOSX10.5.sdk
PostgreSQL_CONFIG_EXECUTABLE     /usr/local/pgsql/bin/pg_config
wxWidgets_CONFIG_EXECUTABLE      /usr/local/bin/wx-config
wxWidgets_USE_DEBUG              OFF
wxWidgets_USE_STATIC             ON
wxWidgets_USE_UNICODE            ON
wxWidgets_wxrc_EXECUTABLE        /usr/bin/wxrc

5) Use the ccmake interface to adjust any settings as required. When configured
   as required, press 'c' to re-configure (if required) and 'g' to generate the 
   build files and exit.

6) Run 'make' to build pgAgent on Mac or Unix, or open the generated project
   files in VC++ on Windows and build the solution in the desired configuration.

XcodeのコマンドラインツールからGCCをすでに持っていました。CMake アプリをインストールしました。私はPostgreSQL 9.4を実行しています。wxMac をダウンロードしましたが、どうすればよいかわかりません。説明書には OS X 10.6 以降で動作すると書かれていますが、ドキュメントは Snow Leopard 専用です。Lion以降を実行しているMacコンピューターでこれを使用している人以外は、これをインストールできません。

私が PgAgent について見つけたもののほとんどは、Windows ユーザー向けのものです。PostgreSQL コマンドの実行をスケジュールする、Mac (Intel) で実装しやすい他のソフトウェアまたはプロセスはありますか?

4

2 に答える 2

1

自動タスクに Cron またはその他のソリューションを使用しようとしましたか? OSXについてはわかりませんが、Linuxでは

クロンタブ

0 22 * * * /var/lib/pgsql/backups/backup.sh database_name
0 0 * * 0 /var/lib/pgsql/backups/backup.sh

バックアップ.sh

BACKUP_DIRECTORY="/var/lib/pgsql/backups"
CURRENT_DATE=$(date "+%Y%m%d")

if [ -z "$1" ]
then
  pg_dumpall | gzip - > $BACKUP_DIRECTORY/pg_dumpall_$CURRENT_DATE.sql.gz
else
  pg_dump $1 | gzip - > $BACKUP_DIRECTORY/$1_$CURRENT_DATE.sql.gz
fi
于 2015-02-07T22:02:18.460 に答える