BUCARDO(1p)
π BUCARDO β the bucardo utility script, manual page BUCARDO(1p) π
User Contributed Perl Documentation β yes bestie, this is the user contributed one, the real ones know π«Ά
β¨ NAME β¨
bucardo β utility script for controlling the Bucardo program. That's it, that's the whole vibe check.
πΈ VERSION πΈ
This document describes version 5.6.0 of bucardo. Iconic behavior only, no cap.
π USAGE π
bucardo [<options>] <command> [<action>] [<command-options>] [<command-params>]
π¦ DESCRIPTION π¦
Okay so, the bucardo script is the main way you talk to a running Bucardo instance. It's literally your one-stop group chat with Bucardo. You can use it to:
- start and stop Bucardo
- add new items
- kick syncs
- and honestly? even install and upgrade Bucardo itself π
For the more complete documentation, please go look at the wiki at https://bucardo.org/. That's where the deep lore lives.
π COMMANDS π
Run bucardo help <command> for additional details. Yes, the help command is self-aware, we love that for it.
installβ Installs the Bucardo configuration database. πΎupgradeβ Upgrades the Bucardo configuration database to the latest schema. Glow-up time β¨start [<start options>] [<reason>]β Starts Bucardo. πstop [<reason>]β Stops Bucardo. πrestart [<start options>] [<reason>]β Stops and starts Bucardo. The ol' razzle dazzle πlist <type> [<regex>]β Lists objects managed by Bucardo. πadd <type> <name> <parameters>β Adds a new object. βupdate <type> <name> <parameters>β Updates an object. πremove <type> <name> [<name>...]β Removes one or more objects. ποΈkick <syncname> [<sync options>] [<syncname>...] [<timeout>]β Kicks off one or more syncs. π₯Ύreload configβ Sends a message to all CTL and KID processes asking them to reload the Bucardo configuration. π¨reopenβ Sends a message to all Bucardo processes asking them to reopen any log files they may have open. Call this after you have rotated the log file(s). πshow all|<setting> [<setting>...]β Shows the current Bucardo settings. π<set <setting=value" [<setting=value>...] >>β Sets one or more configuration setting.. (yes, that's exactly how it's written in the original, and the double period is also canon, do not perceive me π)ping [<timeout>]β Sends a ping notice to the MCP process to see if it will respond. πstatus [<status options>] <syncname> [<syncname>...]β Shows the brief status of syncs in a tabular format. πactivate <syncname> [<syncname>...] [<timeout>]β Activates one or more named syncs. π’deactivate <syncname> [<syncname>...] [<timeout>]β Deactivates one or more named syncs. π΄message '<body>'β Sends a message to the running Bucardo logs. π¬reload [<syncname> [<syncname>...]]β Sends a message to one or more sync processes, instructing them to reload. πinspect <type> <name> [<name>...]β Inspects one or more objects of a particular type. πvalidate all|<syncname> [<syncname>...]β Validates one or more syncs. βpurge all|<table> [<table>...]β Purges the delta and track tables for one or more tables, for one or more databases. π§Ήdelta [<database(s)>]β Show the delta counts for each source target. πhelp [<command> [<action>]]β Shows help. π
π OPTIONS π
-d,--db-name NAMEβ Database name.-U,--db-user USERβ Database user name.-P,--db-pass PASSβ Database password.-h,--db-host HOSTβ Database server host name.-p,--db-port PORTβ Database server port number.--bucardorc FILEβ Use specified.bucardorcfile.--no-bucardorcβ Do not use.bucardorcfile.--quietβ Incremental quiet. π€«--verboseβ Incremental verbose mode. π£οΈ-?,--helpβ Output basic help and exit.--versionβ Print the version number and exit.--dryrunβ Do not perform any actual actions. (Practice mode, we love a rehearsal π)--confirmβ Require direct confirmation before changes. π
π§ COMMAND DETAILS π§
Most of the commands take parameters. These may be passed after the command name and, where appropriate, an object name. Parameters take the form of key/value pairs separated by an equal sign (=). For example:
bucardo add db sea_widgets dbname=widgets host=db.example.com
Here dbname and host are parameters.
Many of the commands also use command-line options, which are specified in the normal way. For example, the bucardo add db command could also be written as:
bucardo add db sea_widgets --dbname widgets --dbhost db.example.com
β οΈ However, parameters and options are not directly interchangeable in all cases. See the documentation for individual commands for their supported options. Don't just assume, bestie, check the receipts.
πΎ install
bucardo install
Installs the Bucardo schema from the file bucardo.schema into an existing Postgres cluster. The user bucardo and database bucardo will be created first as needed. This is an interactive installer, but you can supply the following values from the command line:
--dbuserβ defaults topostgres--dbnameβ defaults topostgres--dbportβ defaults to5432--pid-dirβ defaults to/var/run/bucardo/
β¬οΈ upgrade
bucardo upgrade
Upgrades an existing Bucardo installation to the current version of the bucardo database script. Requires that bucardo and the bucardo.schema file be the same version. All changes should be backwards compatible, but you may need to re-validate existing scripts to make sure changes get propagated to all databases. Fr fr, don't skip the re-validate step.
π start
bucardo start "Reason"
Starts Bucardo. Fails if the MCP process is running (determined if its PID file is present). Otherwise, starts cleanly by first issuing the equivalent of a stop to ask any existing Bucardo processes to exit, and then starting a new Bucardo MCP process. A short reason and name should be provided β these are written to the reason_file file (./bucardo.restart.reason.txt by default) and sent in the email sent when Bucardo has been started up. It is also appended to the reason log, which has the same name as the the reason_file but ends in .log.
The options for the start command are:
--sendmailβ Tells Bucardo whether or not to send mail on interesting events: startup, shutdown, and errors. Default is on.--extra-name stringβ A short string that will be appended to the version string as output by the Bucardo process names. Mostly useful for debugging.--log-destination destinationβ Determines the destination for logging output. The supported values are:stderrstdoutsyslognone- A file system directory.
May be specified more than once, which is useful for, e.g., logging both to a directory and to syslog. If --log-destination is not specified at all, the default is to log to files in /var/log/bucardo.
--log-separateβ Forces creation of separate log files for each Bucardo process of the formlog.bucardo.X.Y, whereXis the type of process (MCP,CTL, orKID), andYis the process ID.--log-extension stringβ Appends the given string to the end of the default log file name,log.bucardo. A dot is added before the name as well, so a log extension ofrootdbwould produce a log file namedlog.bucardo.rootdb.--log-cleanβ Forces removal of all old log files before running. π§Ό--debug,--no-debugβ Enable or disable debugging output. Disabled by default.--exit-on-nosync,--no-exit-on-nosyncβ On startup, if Bucardo finds no active syncs, it normally will continue to run, requiring a restart once syncs are added. This is useful for startup scripts and whatnot.
If, however, you want it to exit when there are no active syncs, pass the --exit-on-nosync option. You can also be explicit that it should not exit when there are no syncs by passing --no-exit-on-nosync. This is the default value.
π stop
bucardo stop "Reason"
Forces Bucardo to quit by creating a stop file which all MCP, CTL, and KID processes should detect and cause them to exit. Note that active syncs will not exit right away, as they will not look for the stop file until they have finished their current run. Typically, you should scan the list of processes after running this program to make sure that all Bucardo processes have stopped. One should also provide a reason for issuing the stop β usually this is a short explanation and your name. This is written to the reason_file file (./bucardo.restart.reason.txt by default) and is also used by Bucardo when it exits and sends out mail about its death. It is also appended to the reason log, which has the same name as the the reason_file but ends in .log.
π restart
bucardo restart "Reason"
Stops bucardo, waits for the stop to complete, and then starts it again. Supports the same options as "start" (/start). Useful for start scripts. For getting just CTL and KID processes to recognize newly added, updated, or removed objects, use the reload command, instead. (Important distinction, don't come for me.)
π list
bucardo list <type> <regex>
Lists summary information about Bucardo objects. The supported types are:
databasedbgrouprelgroupsynctablesequencecustomcodecustomnamecustomcolsall
The all option will list information about all object types. π―
The optional regex option can be used to filter the list to only those matching a regular expression. Filtered, curated, aesthetic.
β add
bucardo add <type> <name> <parameters>
Adds a new object to Bucardo. The type specifies the type of object to add, while the name should be the name of the object. The supported types include:
dbdbgrouptablesequenceall tablesall sequencesrelgroupsynccustomnamecustomcols
ποΈ add db
bucardo add db <name> dbname=actual_name port=xxx host=xxx user=xxx
Adds one or more new databases. The name is the name by which the database will be known to Bucardo, and must be unique. This may vary from the actual database name, as multiple hosts might have databases with the same name. Multiple databases can be added by separating the names with commas. Options that differ between the databases should be separated by a matching commas. Example:
bucardo add db alpha,beta dbname=sales host=aa,bb user=bucardo
This command will attempt an immediate test connection to the added database(s). The supported named parameters are:
dbnameβ The actual name of the database. Required unless using a service file or setting it viadbdsn.typeβ The type of the database. Defaults topostgres. Currently supported values are:postgresdrizzlemongomysqlmariaoracleredissqlite
...and that's only part 1, bestie β there's more where this came from π
"dbdsn"β a direct DSN to connect to a database. If this is set, it overrides ALL the other connection options, periodt."user"β the username Bucardo uses when connecting to this database. π"pass"β the password Bucardo uses when connecting to this database. ngl bestie, it's recommended you use a.pgpassfile instead of putting the password right here. π"host"β the host Bucardo uses when connecting to this database. Defaults to whatever$PGHOSTADDRor$PGHOSTis set to, if they're around. π"port"β the port Bucardo uses when connecting to this database. Defaults to the value of the$PGPORTenvironment variable, if it exists. πͺ"conn"β extra connection parameters, like"sslmode=require"for example. β¨"service"β the service name Bucardo uses when connecting to this database. π"status"β the initial status of this database. Defaults to"active", but you can set it to"inactive"too. π€"dbgroup"β the name of the database group this database should belong to. π«"addalltables"β automatically add every table from this database. πͺ"addallsequences"β automatically add every sequence from this database. π"server_side_prepares","ssp"β set to1or0to enable or disable server-side prepares. Defaults to1. π§"makedelta"β set to1or0to enable or disable makedelta. Defaults to0. π
Additional parameters:
--forceβ forces the database to be added without running a connection test. No vibe check, just go. π€
Note: as a lil convenience, if the"dbuser"value is its default value,bucardo, and Bucardo can't connect to the database, it'll try connecting aspostgresand create a superuser namedbucardo. This is to make life easier for folks getting started with Bucardo, but it will NOT work if it can't connect aspostgres, or if the connection failed because of an authentication failure. π
ποΈ add dbgroup
bucardo add dbgroup name db1:source db2:source db3:target ...
Adds one or more databases to the named dbgroup. If the dbgroup doesn't exist yet, boom, it gets created. The database parameters need to specify their roles, either source or target. π―
ποΈ add table
bucardo add table [schema].table db=actual_db_name
Adds a table object. The table info gets read from the specified database. Supported parameters:
"db"β the name of the database to read the table information from. It should be a name Bucardo already knows, thanks to a previous call toadd database. Required, bestie."autokick"β boolean for whether the table should automatically send kick messages when it's modified. This overrides the"autokick"parameter of any syncs the table is part of. π¦΅"rebuild_index"β boolean for whether to rebuild indexes after every sync. Off by default. Optional. π¨"analyze_after_copy"β boolean for whether to analyze the table after every sync. Off by default. Optional. π"vacuum_after_copy"β boolean for whether to vacuum the table after every sync. Off by default. Optional. π§Ή"relgroup"β adds the table to the named relgroup. If the relgroup doesn't exist, it gets created. Optional. π«Ά"makedelta"β turns makedelta magic on or off. The value is a list of databases that need makedelta for this table. You can also set it to"on"to enable makedelta for all databases. Defaults to"off". β¨"strict_checking"β boolean for whether to be strict when comparing the table between syncs. If the columns have different names or data types, validation fails. But maybe those columns are allowed to have different names or data types? If so, disable"strict_checking"and column differences become warnings instead of a failed validation. Defaults to true. βοΈ
ποΈ add sequence
bucardo add sequence [schema].sequence relgroup=xxx
"db"β the name of the database to read the sequence information from. Should be a name Bucardo knows, thanks to a previous call toadd database. Required."relgroup"β adds the sequence to the named relgroup. If the relgroup doesn't exist, it gets created. Optional. π
ποΈ add all tables
bucardo add all tables [relgroup=xxx] [pkonly]
Adds all the tables in all known databases, or in a specified database. It excludes tables in the pg_catalog, information_schema, and bucardo schemas. (Yes, this means you can't replicate the Bucardo configuration database using Bucardo. Sorry about that. π) Supported options and parameters:
"db",--dbβ name of the database to find all the tables to add from. If you don't provide it, tables get added from all known databases. π"schema",--schema,-nβ limit to the tables in the specified comma-delimited list of schemas. You can specify this option more than once. π"exclude-schema",--exclude-schema,-Nβ exclude tables in the specified comma-delimited list of schemas. You can specify this option more than once. π«"table",--table,-tβ limit to the specified tables. You can specify this option more than once. π―"exclude-table",--exclude-table,-Tβ exclude the specified tables. You can specify this option more than once. π"relgroup",--relgroupβ name of the relgroup to add new tables to. π«"pkonly"β exclude tables without primary keys. π
ποΈ add all sequences
bucardo add all sequences relgroup=xxx
Adds all the sequences in all known databases, or in a specified database. It excludes sequences in the pg_catalog, information_schema, and bucardo schemas. (Yes, again, this means you can't replicate the Bucardo configuration database using Bucardo. Sorry about that. π) Supported options and parameters:
"db",--dbβ name of the database to find all the sequences to add from. If you don't provide it, sequences get added from all known databases. π"schema",--schema,-nβ limit to the sequences in the specified comma-delimited list of schemas. You can specify this option more than once. π"exclude-schema",--exclude-schema,-Nβ exclude sequences in the specified comma-delimited list of schemas. You can specify this option more than once. π«"relgroup",--relgroupβ name of the relgroup to add new tables or sequences to. π«Ά
ποΈ add relgroup
bucardo add relgroup name
bucardo add relgroup name table, sequence, ...
Adds a relgroup. After the name, pass in an optional list of tables and/or sequences and they get added to the group. π
ποΈ add sync
bucardo add sync name relgroup=xxx dbs=xxx
Adds a sync, which is a named replication event containing info about what to replicate from where to where. The main character of the whole operation, honestly. π The supported parameters are:
"dbs"β the name of a dbgroup or a comma-delimited list of databases. All of the specified databases get synchronized. Required."dbgroup"β the name of a dbgroup. All the databases inside this group become part of the sync. If the dbgroup doesn't exist and a separate list of databases is given, the group gets created and populated. π«"relgroup"β the name of a relgroup to synchronize. All the tables and/or sequences in the relgroup get synchronized. Required unless"tables"is specified."tables"β list of tables to add to the sync. This implicitly creates a relgroup with the same name as the sync. Required unless"relgroup"is specified."status"β indicates whether the sync is active. Must be either"active"or"inactive". Defaults to"active". π«"rebuild_index"β boolean for whether to rebuild indexes after every sync. Defaults to off. π¨"lifetime"β number of seconds a KID can live before being reaped. No limit by default. β³"maxkicks"β number of times a KID may be kicked before being reaped. No limit by default. π¦΅"conflict_strategy"β the conflict resolution strategy to use in the sync. Supported values:"bucardo_source"β the rows on thesourcedatabase always"win". In other words, in a conflict, Bucardo copies rows from source to target. π"bucardo_target"β the rows on thetargetdatabase always win. π"bucardo_skip"β any conflicting rows are simply not replicated. Not recommended for most cases. π"bucardo_random"β each database has an equal chance of winning each time. This is the default. π²"bucardo_latest"β the row that was most recently changed wins. β°"bucardo_abort"β the sync is aborted on a conflict. π
"onetimecopy"β determines whether a sync should switch to a full copy mode for a single run. Supported values are:0: off1: always full copy2: only copy tables that are empty on the target
"stayalive"β boolean for whether the sync processes (CTL) should be persistent. Defaults to false. π«"kidsalive"β boolean for whether the sync child processes (KID) should be persistent. Defaults to false. π§"autokick"β boolean for whether tables in the sync should automatically send kick messages when they're modified. May be overridden by the"autokick"parameter of individual tables. π¦΅"checktime"β an interval specifying the maximum time a sync should go before being kicked. Useful for busy systems where you don't want the overhead of notify triggers. β±οΈ"priority"β an integer indicating the priority of the sync. Lower numbers are higher priority. Currently used only for display purposes. π"analyze_after_copy"β boolean for whether to analyze tables after every sync. Off by default. Optional. π"overdue"β an interval specifying the amount of time after which the sync has not run that it should be considered overdue."check_bucardo_sync"issues a warning when a sync hasn't been run in this amount of time. β οΈ"expired"β an interval specifying the amount of time after which the sync has not run that it should be considered expired."check_bucardo_sync"issues a critical message when a sync hasn't been run in this amount of time. π¨"track_rates"β boolean for whether to track synchronization rates. πrebuild_indexβ a Boolean for whether we rebuild indexes after every single sync or not. Off by default. Optional, bestie. πstrict_checkingβ a Boolean for whether we're being strict when comparing tables in the sync. If the columns have different names or data types, the validation just fails. But maybe those columns are allowed to have different names or data types? If so, turnstrict_checkingoff and column differences become warnings instead of a validation fail. Defaults totrue. π
β¨ add customname β¨
bucardo add customname oldname newname [db=name] [sync=name]
Makes a new Bucardo custom name mapping. This is the glow-up that lets the tables in replication have different names on different databases. The oldname must include the schema as well as the table name (as long as the source database supports schemas, anyway). The optional params keep it scoped to one or more databases, and/or one or more syncs. Here's what you can pass:
syncβ a sync to add the customname to. You can pass this multiple times. πdatabase,dbβ a database to add the customname to. Also can be passed multiple times. π
πΈ add customcols πΈ
bucardo add customcols tablename select_clause [sync=x db=x]
This one lets you pick the exact list of columns to select from when syncing. Instead of the default SELECT * behavior, you can specify literally any columns you want β including function call return values and things that aren't even in the source column list. The optional params scope it to one or more databases, and/or one or more syncs. Some examples, because examples are self-care:
bucardo add customcols public.foobar "select a, b, c"
bucardo add customcols public.foobar "select a, upper(b) AS b, c" db=foo
bucardo add customcols public.foobar "select a, b, c" db=foo sync=abc
Supported params:
syncβ a sync to add the customcols to. May be specified multiple times. β¨database,dbβ a database to add the customcols to. May be specified multiple times. β¨
π¦ add customcode π¦
bucardo add customcode <name> <whenrun=value> <src_code=filename> [optional information]
Adds a customcode, which is a Perl subroutine that runs at certain points in the sync process. It might handle exceptions, handle conflicts, or just vibe at certain times with no expectation of functionality (like, say, before Bucardo drops triggers). Metadata about that point gets passed to the subroutine as a hash reference. π«Ά
Supported parameters:
nameβ the name of the custom code object.aboutβ a short description of the custom code.whenrun,when_runβ a string saying when the custom code should run. Supported values include:before_txnbefore_check_rowsbefore_trigger_dropafter_trigger_dropafter_table_syncexceptionconflictbefore_trigger_enableafter_trigger_enableafter_txnbefore_syncafter_sync
getdbhβ a Boolean for whether Perl DBI database handles should be handed to the custom code subroutine. If true, database handles show up under thedbhkey of the hash reference passed to the subroutine. The value under this key will be a hash reference mapping database names to their respective handles.syncβ name of the sync to associate the custom code with. Cannot be used together withrelation. πrelationβ name of the table or sequence to associate the custom code with. Cannot be used together withsync. πstatusβ the current status of this customcode. Anything other thanactivemeans the code does not run.priorityβ a number for the order in which to execute custom codes. Lower numbers = higher priority. Super useful for subroutines that setlastcodeso they can cancel the execution of subsequent custom codes for the samewhen_run.src_codeβ the file to read the custom code Perl source from.
The body of the Perl subroutine should live in the src_code file, and not inside a sub declaration. When it gets called, it's passed a single hash reference with these keys:
syncnameβ the name of the currently-executing sync.versionβ the version of Bucardo executing the sync.sourcenameβ the name of the source database.targetnameβ the name of the target database.sendmailβ a code reference you can use to send email messages.sourcedbhβ a DBI database handle to the sync source database. Only provided to custom code executed by the controller.rellistβ an array reference of hash references, each one representing a relation in the sync. Only provided to custom code executed by the controller. The keys in the hash are the same as the parameters supported byadd tableandadd sequence, as appropriate.schemanameβ the schema for the table that triggered the exception. Only provided toexceptioncustom codes.tablenameβ the name of the table that triggered the exception. Only provided toexceptioncustom codes.error_stringβ the string containing the actual error message. Only provided toexceptioncustom codes.deltabinβ a hash reference with the name of each source database as a key and a list of all primary keys joined together with\0. Only provided toexceptioncustom codes.attemptsβ the number of times the sync has been attempted. Only provided toexceptioncustom codes.conflictsβ a hash reference of conflicting rows. The keys are the primary key values, and the values are hash references with the names of the databases containing the conflicting rows and true values. Only provided toconflictcustom codes.
The custom code subroutine may set any of these keys in the hash reference to change the behavior of the sync:
messageβ message to send to the logs.warningβ a warning to emit after the subroutine has returned.errorβ an error to be thrown after the subroutine has returned.nextcodeβ set it to send execution to the next custom code of the same type. Mainly useful for exception custom codes, and supported only by custom codes executed by the controller.lastcodeβ set it to true and any subsequent custom codes of the same type get skipped. πendsyncβ cancels the sync altogether.
An example, bestie, feast your eyes:
use strict;
use warnings;
use Data::Dumper;
my $info = shift;
# Let's open a file.
my $file = '/tmp/bucardo_dump.txt';
open my $fh, '>:encoding(UTF-8)', $file or do {
$info->{warning} = "Cannot open $file: $!\n";
return;
};
# Inspect $info for fun.
print $fh Dumper $info;
close $fh or $info->{warning} = "Error closing $file: $!\n";
# Log a message and return.
$info->{message} = 'IN UR DATABASEZ NORMALIZIN UR RELAYSHUNS';
return;
π update π
bucardo update <type> <name> <parameters>
Updates a Bucardo object. The type says which kind of object we're updating, and name should be the name of that object. The supported parameters for each type are the same ones as for add. The supported types are:
customcodedbsynctablesequence
β update customcode β
bucardo update customcode <name> setting=value
Updates an existing customcode. The stuff you can change:
aboutβ a short description of the custom code.getdbhβ a Boolean for whether Perl DBI database handles should be handed to the custom code subroutine. If true, database handles show up under thedbhkey of the hash reference passed to the subroutine. The value under this key will be a hash reference mapping database names to their respective handles.nameβ the name of the custom code object.priorityβ a number for the order in which to execute custom codes. Lower numbers = higher priority. Useful for subroutines that setlastcodeso they can cancel the execution of subsequent custom codes for the samewhen_run.src_codeβ the file to read the custom code Perl source from.statusβ the current status of this customcode. Anything other thanactivemeans the code does not run.whenrunβ a string saying when the custom code should run. Supported values include:before_txnbefore_check_rowsbefore_trigger_dropafter_trigger_dropafter_table_syncexceptionconflictbefore_trigger_enableafter_trigger_enableafter_txnbefore_syncafter_sync
π update db π
bucardo udpate db <name> port=xxx host=xxx user=xxx pass=xxx
Updates a database. The name is the name the database is known by to Bucardo. Heads up: this can be different from the actual database name, because multiple hosts might have databases with the same name. π
The supported named parameters are:
dbname,dbβ the actual name of the database.type,dbtypeβ the type of the database. Currently supported values are:postgresdrizzlemongomysqlmariaoracleredissqlite
username,dbuser,dbdsnβ a direct DSN to connect to a database. This one overrides all other connection options if it's set.userβ the username Bucardo should use to connect to the database.password,dbpass,passβ the password Bucardo should use when connecting to the database. π€«dbhost,pghost,hostβ the host name to connect to.dbport,pgport,portβ the port to connect to.dbconn,pgconn,connβ additional connection parameters, e.g.sslmode=require. Optional.statusβ status of the database in Bucardo. Must be eitheractiveorinactive.dbgroup,server_side_prepares,sspβ enable or disable server-side prepares. Pass1to enable them or0to disable them.makedeltaβ enable or disable makedelta for this database.dbservice,serviceβ the service name to use for a Postgres database. β¨dbgroupβ a comma-separated list of dbgroups to add the database to. Heads up bestie: the database gets removed from every other dbgroup it used to be in. It's giving "new group, who dis". π
π update sync π
bucardo update sync syncname relgroup=xxx dbs=xxx
Updates a sync β which is basically a named replication event that holds all the info about what to replicate from where to where. Here's everything you can pass it:
nameβ the name of the sync. Required, no skips. πdbsβ the name of a dbgroup, or a comma-delimited list of databases.relgroupβ the name of the relgroup to synchronize.statusβ whether the sync is active or not. Gotta be either"active"or"inactive". β οΈ Important tho: this does not change the current run status of the sync, it just marks whether it should be active or inactive on the next reload. If you actually wanna activate or deactivate a sync, use theactivate syncanddeactivate synccommands. Periodt.rebuild_indexβ boolean, whether or not to rebuild indexes after every sync.lifetimeβ number of seconds a KID can live before being reaped. πmaxkicksβ number of times a KID may be kicked before being reaped.isolation_levelβ the transaction isolation level this sync should use. The only choices are"serializable"and"repeatable read". That's it, that's the whole menu.conflict_strategyβ the conflict resolution strategy for the sync. Supported values:bucardo_sourceβ rows on the"source"database always win. In a conflict, Bucardo copies rows from source to target.bucardo_targetβ rows on the"target"database always win. πbucardo_latestβ the row that was most recently changed wins.bucardo_abortβ the sync just aborts on a conflict. π
onetimecopyβ decides whether a sync should switch into full copy mode for a single run. Supported values:0: off1: always full copy2: only copy tables that are empty on the target
stayaliveβ boolean, whether the sync processes (CTL) should be persistent.kidsaliveβ boolean, whether the sync child processes (KID) should be persistent.autokickβ boolean, whether tables in the sync should automatically send kick messages when they're modified. Can be overridden by theautokickparameter of individual tables, iykyk.checktimeβ an interval for the maximum time a sync should go before being kicked. Super useful for busy systems where you don't want the overhead of notify triggers. π₯priorityβ an integer for the priority of the sync. Lower numbers = higher priority. Currently it's only used for display purposes, so don't get too attached.analyze_after_copyβ boolean, whether to analyze tables after every sync. Off by default.overdueβ an interval for how long after a sync hasn't run it should be considered overdue.check_bucardo_syncthrows a warning when a sync hasn't run in that amount of time. π«Άexpiredβ an interval for how long after a sync hasn't run it should be considered expired.check_bucardo_syncthrows a critical message when a sync hasn't run in that amount of time. π¨track_ratesβ boolean, whether or not to track synchronization rates.rebuild_indexβ boolean, whether or not to rebuild indexes after every sync. (Yes bestie, it's listed twice in the source. Not a typo on my end, I promise. π)strict_checkingβ boolean, whether to be strict when comparing tables in the sync. If the columns have different names or data types, validation fails. But maybe those columns are allowed to have different names or data types? Then turnstrict_checkingoff and column differences become warnings instead of failing the validation. Defaults to true.
πΈ update table πΈ
bucardo update table [schema].table db=actual_db_name
Updates a table object. The table info gets read from the database you specify. Supported parameters:
dbβ the name of the database to read the table info from. Should be a name Bucardo already knows about.schemanameβ the name of the schema the table lives in.tablenameβ the actual name of the table.autokickβ boolean, whether the table should automatically send kick messages when it's modified. This overrides theautokickparameter of any syncs the table is part of. πrebuild_indexβ boolean, whether or not to rebuild indexes after every sync.analyze_after_copyβ boolean, whether or not to analyze the table after every sync.vacuum_after_copyβ boolean, whether or not to vacuum the table after every sync.relgroupβ adds the table to the named relgroup. Can be specified more than once. The table gets removed from any other relgroups. π¦makedeltaβ specifies which databases need makedelta enabled for this table.strict_checkingβ boolean, whether to be strict when comparing the table between syncs. If the columns have different names or data types, validation fails. But maybe those columns are allowed to differ? Then turnstrict_checkingoff and column differences become warnings instead of failing the validation. Defaults to true.
π update sequence π
bucardo update sequence [schema].sequence relgroup=xxx
dbβ the name of the database where the sequence lives.schemanameβ the name of the schema the sequence is found in.relgroupβ adds the sequence to the named relgroup. Can be specified more than once. The sequence gets removed from any other relgroups. β¨
π remove π
bucardo remove <item_type> <item_name>
Removes one or more objects from Bucardo. Valid item types are:
dbordatabaseβ use the--forceoption to clear out related tables and groups instead of erroring out. β οΈdbgrouprelgroupsynctablesequencecustomcolscustomnamecustomcode
β‘ kick β‘
bucardo kick <syncname(s)> [timeout]
Tells one or more named syncs to fire ASAP. Lowkey important tho: this just sends a request that the sync fire β it might not start right away if the same sync is already running, or if the source or target database has exceeded the number of allowed Bucardo connections. π
If the final argument is a number, it's treated as a timeout. If that number is zero, the bucardo command won't return until the sync has finished. For any other number, the sync waits at most that many seconds. If any sync hasn't finished before the timeout, you get an exit value of 1. Errors cause exit values of 2 or 3. In all other cases, exit value 0 is returned. β¨
If a timeout is given, the total completion time in seconds is also displayed. If the sync is going to multiple targets, the time each target takes from the start of the kick is shown as each target finishes. Options:
--retryβ the number of times to retry a sync if it fails. Defaults to0.--retry-sleepβ how long to sleep, in seconds, between each retry attempt.--notimerβ by default, kicks with a timeout argument give a running real-time summary of time elapsed using the backspace character. That might be unwanted if you're running a kick via, like, a cronjob π β so turning--notimeron just prints the entire message without backspaces.
βΈοΈ pause βΈοΈ
bucardo pause <syncname(s)>
bucardo pause all
bucardo resume <syncname(s)>
bucardo resume all
Tells one or more named syncs to temporarily pause, or to resume from a previous pause. This only applies to active syncs and only takes effect if Bucardo is currently running. You can also use the keyword all to pause or resume every known active sync. π
π reload config π
bucardo reload config
bucardo reload config 30
Sends a message to all CTL and KID processes asking them to reload the Bucardo configuration. This configuration is a series of key/value pairs that configure Bucardo's behavior β not any of the objects managed by the add, remove, or update commands. Don't mix those up bestie.
By default, Bucardo sends the message and then exits. Pass an optional number and Bucardo will instead wait up to that length of time for all child processes to report completion. π«Ά
π set π
bucardo set setting1=value [setting2=value]
Sets one or more rows in the configuration setting table. Setting names are case-insensitive. The available settings are:
autosync_ddlβ which DDL changing conditions do we try to remedy automatically? Default:newcol.bucardo_versionβ current version of Bucardo. Default:5.6.0.bucardo_vacβ do we want the automatic VAC daemon to run? Default:1.bucardo_initial_versionβ the Bucardo version this schema was created with. Default:5.6.0.ctl_checkonkids_timeβ how often does the controller check on the kids' health? Default:10.ctl_createkid_timeβ how long do we sleep to allow kids-on-demand to get on their feet? Default:0.5.ctl_sleepβ how long does the controller loop sleep? Default:0.2.default_conflict_strategyβ default conflict strategy for all syncs. Default:bucardo_latest.default_email_fromβ who the alert emails are sent as. Default:nobody@example.com.default_email_hostβ which host to send email through. Default:localhost.default_email_toβ who to send alert emails to. Default:nobody@example.com.email_debug_fileβ file to save a copy of all outgoing emails to. Default:None.endsync_sleepβ how long do we sleep when custom code requests an endsync? Default:1.0.flatfile_dirβ directory to store the flatfile output inside of. Default:".".host_safety_checkβ regex to make sure we don't accidentally run where we should not. Default:None. πisolation_levelβ the transaction isolation level all syncs should use. Defaults toserializable. The only other valid option isrepeatable read."kid_deadlock_sleep"β how long to sleep in seconds if we hit a deadlock error. Default:0.5. Set to-1to prevent the kid from retrying. π"kid_nodeltarows_sleep"β how long do kids sleep if no delta rows are found? Default:0.5. π΄"kid_pingtime"β how often do we ping check the KID? Default:60. π"kid_restart_sleep"β how long to sleep in seconds when restarting a kid? Default:1. π"kid_serial_sleep"β how long to sleep in seconds if we hit a serialization error. Default:0.5. Set to-1to prevent the kid from retrying. π«"kid_sleep"β how long does a kid loop sleep? Default:0.5. π€"log_conflict_file"β name of the conflict detail log file. Default:"bucardo_conflict.log". π"log_level"β how verbose to make the logging. Higher is more verbose. Default:"normal". π"log_microsecond"β show microsecond output in the timestamps? Default:0. β±οΈ"log_showlevel"β show log level in the log output? Default:0. π"log_showline"β show line number in the log output? Default:0. π"log_showpid"β show PID in the log output? Default:1. π"log_showtime"β show timestamp in the log output?0=off,1=seconds since epoch,2=scalar gmtime,3=scalar localtime. Default:3. π"log_timer_format"β the"strftime"format to use to format the log timestamp when"log_showtime"is set to2or3. Defaults to simply the scalar output of the time. π°οΈ"mcp_dbproblem_sleep"β how many seconds to sleep before trying to respawn. Default:15. π΄"mcp_loop_sleep"β how long does the main MCP daemon sleep between loops? Default:0.2. π"mcp_pingtime"β how often do we ping check the MCP? Default:60. π"mcp_vactime"β how often in seconds do we check that a VAC is still running? Default:60. π§"piddir"β directory holding Bucardo PID files. Default:"/var/run/bucardo". π"reason_file"β file to hold reasons for stopping and starting. Default:"bucardo.restart.reason.txt". π"reload_config_timeout"β number of seconds the"reload_config"command should wait for the reload to complete. Default:30. β³"semaphore_table"β table to let apps know a sync is ongoing. Default:"bucardo_status". π¦"statement_chunk_size"β how many primary keys to shove into a single statement. Default:10000. π¦"stats_script_url"β location of the stats script. Default:"http://www.bucardo.org/". π"stopfile"β name of the semaphore file used to stop Bucardo processes. Default:"fullstopbucardo". π"syslog_facility"β which syslog facility level to use. Default:"log_local1". π"tcp_keepalives_count"β how many probes to send.0indicates sticking with system defaults. Default:0. π‘"tcp_keepalives_idle"β how long to wait between each keepalive probe. Default:0. β²οΈ"tcp_keepalives_interval"β how long to wait for a response to a keepalive probe. Default:0. β±οΈ"vac_run"β how often does the VAC process run? Default:30. π"vac_sleep"β how long does VAC process sleep between runs? Default:120. π΄"warning_file"β file containing all log lines starting with"Warning". Default:"bucardo.warning.log". β οΈ
show
bucardo show all|changed|<setting> [<setting>...]
Shows the current Bucardo settings. Use the keyword "all" to see all the settings, "changed" to see settings different than the installed defaults, or specify one or more search terms. See "set" for complete details on the configuration settings. π
config
bucardo config show all|<setting> [<setting>...]
bucardo config set <setting=value> [<setting=value>...]
Deprecated interface for showing and setting configuration settings. Use the "show" and "set" commands, instead.
π« Bestie, this is deprecated. Just useshowandset, okay?
ping
bucardo ping
bucardo ping 60
bucardo ping 0
Sends a ping notice to the MCP process to see if it will respond. By default, it will wait 15 seconds. A numeric argument will change this timeout. Using a 0 as the timeout indicates waiting forever. If a response was returned, the program will exit with a value of 0. If it times out, the value will be 1. Returns a Nagios like message starting with "OK" or "CRITICAL" for success or failure. π
status
bucardo status [syncname(s)] [--sort=#] [--show-days] [--compress]
Shows the brief status of all known syncs in a tabular format. If given one or more sync names, shows detailed information for each one. To see detailed information for all syncs, simply use "status all".
When showing brief information, the columns are:
- Name β the name of the sync
- State β the state of the sync. Can be
'Good','Bad','Empty','No records found','Unknown', or the run state for a currently-running sync. - Last good β when the sync last successfully ran.
- Time β how long it has been since the last sync success
- Last I/U β the number of insert and deletes performed by the last successful sync. May also show the number of rows truncated (
T) or conflicted (C), if applicable. - Last bad β when the sync last failed.
- Time β how long it has been since the last sync failure
The options for "status" are:
--show-daysβ specifies whether or not do list the time interval with days, or simply show the hours. For example,"3d 12h 6m 3s"vs."48h 6m 3s"--compressβ specifies whether or not to compress the time interval by removing spaces. Mostly used to limit the width of the'status'display.--sort=#β requests sorting of the'status'output by one of the nine columns. Use a negative number to reverse the sort order.
activate
bucardo activate syncname [syncname2 syncname3 ...] [timeout]
Activates one or more named syncs. If given a timeout argument, it will wait until it has received confirmation from Bucardo that each sync has been successfully activated. β¨
deactivate
bucardo deactivate syncname [syncname2 syncname3 ...] [timeout]
Deactivates one or more named syncs. If given a timeout argument, it will wait until it has received confirmation from Bucardo that the sync has been successfully deactivated. π€
message
bucardo message 'I WAS HERE'
Sends a message to the running Bucardo logs. This message will appear prefixed with "MESSAGE: ". If Bucardo is not running, the message will go to the logs the next time Bucardo runs and someone adds another message. π
reload
bucardo reload [syncname2 syncname3 ...]
Sends a message to one or more sync processes, instructing them to reload. Waits for each to reload before going on to the next. Reloading consists of deactivating a sync, reloading its information from the database, and activating it again. π
inspect
bucardo inspect <type> <name> [<name2>...]
Inspects one or more objects of a particular type. The results are sent to "STDOUT". The supported types include:
"table""sync""relgroup"
validate
bucardo validate all|<sync> [<sync>...]
Validates one or more syncs. Use the keyword "all" to validate all syncs, or specify one or more syncs to validate.
π Note: this command executes a subset of all the validation done when a sync is started or activated.
purge
bucardo purge all|<table> [<table>...]
Purges the delta and track tables for one or more tables, for one or more databases. Use the keyword "all" to validate all tables, or specify one or more tables to validate. π§Ή
delta
bucardo delta [total] [<database>...]
Show the current delta count for each source target. Provide a list of databases to limit it to just the given ones. Wildcards are allowed. Use the special name "totals" to show only the grand total. π
help
bucardo help
bucardo help <command>
bucardo help <command> <action>
Get help. General help can be returned, as well as help for a single command or a command and its action. Some examples:
bucard help list
bucard help add table
β¨ OPTIONS DETAILS β¨
ngl, it's usually way easier to set most of these options at the top of your script, or just make an alias for them, because they're not gonna change very often β if at all. π
-d,--db-nameβ Name of the Bucardo database to which to connect.
bucardo --db-name widgets
bucardo -d bricolage
-U,--db-userβ User name to use when connecting to the Bucardo database.
bucardo --db-user postgres
bucardo -U Mom
-P,--db-passβ Password to use when connecting to the Bucardo database.
bucardo --db-pass s3cr1t
bucardo -P lolz
-h,--db-hostβ Host name to use when connecting to the Bucardo database.
bucardo --db-host db.example.com
bucardo -h db2.example.net
-p,--db-portβ Port number to connect to when connecting to the Bucardo database.
bucardo --db-port 7654
--bucardorcβ Use the specified file for configuration instead of the default./.bucardorc.
bucardo --bucardorc myrcfile
--no-bucardorcβ Do not use the./.bucardorcconfiguration file.--verboseβ Makes bucardo run verbosely. Default is off.--quietβ Tells bucardo to be as quiet as possible. Default is off.--helpβ Shows a brief summary of usage for bucardo.
π FILES π
In addition to command-line configurations, you can put any options inside of a file. The file .bucardorc in the current directory will be used if found. If not found, then the file ~/.bucardorc will be used. Finally, the file /etc/bucardorc will be used if available. The format of the file is option = value, one per line. Any line starting with a '#' will be skipped. Any values loaded from a bucardorc file will be overwritten by command-line options. All bucardorc files can be ignored by supplying a "--no-bucardorc" argument. A specific file can be forced with the "--bucardorc=file" option; if this option is set, bucardo will refuse to run unless that file can be read. π
π ENVIRONMENT VARIABLES π
The bucardo script uses $ENV{HOME} to look for a .bucardorc file. π
π BUGS π
Bug reports and feature requests are always welcome, please visit bucardo.org (https://bucardo.org), file GitHub Issues (http://github.com/bucardo/bucardo/issues), or post to our email list (https://bucardo.org/mailman/listinfo/bucardo-general). π«Ά
π SEE ALSO π
Bucardo
Β© COPYRIGHT Β©
Copyright 2006-2020 Greg Sabino Mullane <greg@turnstep.com>
This program is free to use, subject to the limitations in the LICENSE file. π
This page was served by perl v5.32.1, dated 2021-06-30, and it's BUCARDO(1p) β periodt. π
β¨
π¦ where this page comes from
- debian bookworm: bucardo 5.6.0-4
- debian trixie: bucardo 5.6.0-4
- ubuntu jammy: bucardo 5.6.0-4
- ubuntu noble: bucardo 5.6.0-4
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms