• Stars
    star
    1,072
  • Rank 43,150 (Top 0.9 %)
  • Language
    Go
  • License
    Other
  • Created almost 6 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

pg_timetable: Advanced scheduling for PostgreSQL

License: MIT Coverage Status Documentation Status Release Github All Releases Docker Pulls Go Report Card Mentioned in Awesome Go

pg_timetable: Advanced scheduling for PostgreSQL

pg_timetable is an advanced standalone job scheduler for PostgreSQL, offering many advantages over traditional schedulers such as cron and others. It is completely database driven and provides a couple of advanced concepts. It allows you to schedule PostgreSQL commands, system programs and built-in operations:

-- Run public.my_func() at 00:05 every day in August:
SELECT timetable.add_job('execute-func', '5 0 * 8 *', 'SELECT public.my_func()');

-- Run VACUUM at minute 23 past every 2nd hour from 0 through 20 every day:
SELECT timetable.add_job('run-vacuum', '23 0-20/2 * * *', 'VACUUM');

-- Refresh materialized view every 2 hours:
SELECT timetable.add_job('refresh-matview', '@every 2 hours', 
  'REFRESH MATERIALIZED VIEW public.mat_view');

-- Clear log table after pg_timetable restart:
SELECT timetable.add_job('clear-log', '@reboot', 'TRUNCATE public.log');

-- Reindex at midnight on Sundays with reindexdb utility:

--  using default database under default user (no command line arguments)
SELECT timetable.add_job('reindex-job', '0 0 * * 7', 'reindexdb', job_kind := 'PROGRAM');

--  specifying target database and tables, and be verbose
SELECT timetable.add_job('reindex-job', '0 0 * * 7', 'reindexdb',
          '["--table=foo", "--dbname=postgres", "--verbose"]'::jsonb, 'PROGRAM');

--  passing password using environment variable through bash shell
SELECT timetable.add_job('reindex-job', '0 0 * * 7', 'bash',
    '["-c", "PGPASSWORD=5m3R7K4754p4m reindexdb -U postgres -h 192.168.0.221 -v'::jsonb,
    'PROGRAM');    

Documentation

https://pg-timetable.readthedocs.io/

Main features

  • Tasks can be arranged in chains
  • Each task executes SQL, built-in or executable command
  • Parameters can be passed to tasks
  • Missed chains (possibly due to downtime) can be retried automatically
  • Support for configurable repetitions
  • Builtin tasks such as sending emails, downloading, importing files, etc.
  • Fully database driven configuration
  • Full support for database driven logging
  • Enhanced cron-style scheduling
  • Optional concurrency protection

Installation

Complete installation guide can be found in the documentation.

Possible choices are:

Quick Start

Complete usage guide can be found in the documentation.

  1. Download pg_timetable executable

  2. Make sure your PostgreSQL server is up and running and has a role with CREATE privilege for a target database, e.g.

    my_database=> CREATE ROLE scheduler PASSWORD 'somestrong';
    my_database=> GRANT CREATE ON DATABASE my_database TO scheduler;
  1. Create a new job, e.g. run VACUUM each night at 00:30
    my_database=> SELECT timetable.add_job('frequent-vacuum', '30 0 * * *', 'VACUUM');
    add_job
    ---------
          3
    (1 row)
  1. Run the pg_timetable
    # pg_timetable postgresql://scheduler:somestrong@localhost/my_database --clientname=vacuumer
  1. PROFIT!

Supported Environments

Cloud Service Supported PostgreSQL Version Supported OS Supported
Alibaba Cloud βœ… 17 (devel) βœ… Linux βœ…
Amazon RDS βœ… 16 (beta) βœ… Darwin βœ…
Amazon Aurora βœ… 15 (current) βœ… Windows βœ…
Azure βœ… 14 βœ… FreeBSD* βœ…
Citus Cloud βœ… 13 βœ… NetBSD* βœ…
Crunchy Bridge βœ… 12 βœ… OpenBSD* βœ…
DigitalOcean βœ… 11 βœ… Solaris* βœ…
Google Cloud βœ… 10 βœ…
Heroku βœ…
Supabase βœ…

* - there are no official release binaries made for these OSes. One would need to build them from sources.

** - previous PostgreSQL versions may and should work smoothly. Only officially supported PostgreSQL versions are listed in this table.

Contributing

Open in Gitpod

If you want to contribute to pg_timetable and help make it better, feel free to open an issue or even consider submitting a pull request.

Support

For professional support, please contact Cybertec.

Authors

Star History

Star History Chart

More Repositories

1

pgwatch2

PostgreSQL metrics monitor/dashboard
PLpgSQL
1,792
star
2

pg_squeeze

A PostgreSQL extension for automatic bloat cleanup
C
462
star
3

vip-manager

Manages a virtual IP based on state kept in etcd or Consul
Go
195
star
4

pg_show_plans

Show query plans of all currently running SQL statements
C
186
star
5

postgres-showcase

Postgres features showcase (commented SQL samples) for beginners
164
star
6

pgfaceting

Faceted query acceleration for PostgreSQL using roaring bitmaps
PLpgSQL
145
star
7

pg_permissions

A simple set of views to see ALL permissions in a PostgreSQL database
PLpgSQL
143
star
8

ora_migrator

Tools for Oracle to PostgreSQL migration
PLpgSQL
109
star
9

zheap

⚑️ Development status and progress reporting.
HTML
93
star
10

rjsf-material-ui

[Archived] Material UI theme for react-jsonschema-form.
TypeScript
62
star
11

pgwatch

πŸ”¬PGWATCH: PostgreSQL metrics monitor/dashboard
Go
59
star
12

postgres

PostgreSQL with Transparent Data Encryption (TDE)
C
49
star
13

pg_cgroups

PostgreSQL extension to manage Linux Control Groups
C
36
star
14

pg_rewrite

Perform maintenance tasks which require a table to be rewritten (i.e. the table data to be copied to a new storage) and which are expected to limit the access to the table as little as possible
C
34
star
15

pg_crash

Periodically or randomly crash your database
C
26
star
16

safe-backup

Pre- and post-backup scripts for a safe PostgreSQL online file system backup
Shell
25
star
17

cybertec_migrator

CYBERTEC Migrator πŸ—„πŸ”€πŸ—„
Shell
22
star
18

patroni-packaging

Shell
20
star
19

db_migrator

PLpgSQL
18
star
20

react-database-diagram

A react component to render nice database diagram using storm-react-diagrams
TypeScript
17
star
21

patroni-windows-packaging

Automate installing and launching of Patroni under Windows
Batchfile
15
star
22

pg_timetable_gui

GUI for pg_timetable
Pascal
13
star
23

CYBERTEC-pg-operator

Go
12
star
24

pg_sequence_fixer

Fixing PostgreSQL sequences which got out of sync with the data
PLpgSQL
12
star
25

walbouncer

A proxy server for PostgreSQL replication connections with the capability to filter out user defined subsets of data
C
12
star
26

scripts

Various scripts around PostgreSQL management
Python
10
star
27

generic-plan

generate a generic plan for a parameterized SQL statement
PLpgSQL
10
star
28

pg_remote_exec

Run shell commands in SQL prompt
C
8
star
29

drop_role_helper

Generate SQL to revoke all privileges of a role in the current database
PLpgSQL
7
star
30

poc-plpgsql-analyzer

Proof of concept for tooling to migrate PL/SQL code to PL/pgSQL written in Rust
Rust
7
star
31

PES

Patroni Environment Setup
Pascal
6
star
32

walbouncer-companion

A tool to perform a selective Postgres basebackup
Python
6
star
33

essence

β˜• breaks during database dump extraction? Not on our watch!
Rust
4
star
34

merge_ips

PLpgSQL
3
star
35

today-i-learned

TypeScript
3
star
36

python_template

Template repository for Python command line apps.
Python
3
star
37

.github

Repository to share actions and workflows
3
star
38

CYBERTEC-operator-tutorials

3
star
39

yaim

yaim - yet another ip manager
Go
2
star
40

postgresql-action

:octocat: GitHub Action for PostgreSQL
2
star
41

layman

fuse-overlayfs within Docker for volume mounts.
Shell
2
star
42

debezium2postgres

Application to apply CDC log from Debezium to the destination PostgreSQL
Go
2
star
43

pgbackrest-tde

pgbackrest fork, patched for PostgreSQL-TDE
C
2
star
44

patroni-infoblox-integration

Patroni callbacks for integrating into Infoblox DNS services
Python
2
star
45

CYBERTEC-pg-container

Python
1
star
46

today-i-learned-content

This repository contains all the content for Today I learned @Cybertec-postgresql.
Shell
1
star
47

postgresql

A fork of https://salsa.debian.org/postgresql/postgresql/
1
star