lunes, 29 de julio de 2013

Adempiere Light Backup

1) Abrir una terminal Ctrl + Alt + t

sudo pg_dump -Fc -h [IP Servidor] adempiere -U adempiere -v -W -T 'ad_changelog' > adempierefile.backup

Example:

pg_dump -Fc -h localhost -d idempiere -U adempiere -v -W -T 'ad_changelog' -T 'ad_issue' > "C:\dbname230221_1614.backup"

2) Antes de restaurar la base de datos, se debe crear el lenguage plpgsql con la siguiente instrucción:

create language plpgsql;

3) Cuando se vaya a restaurar la base de datos, es necesario crear la estructura de la tabla 'ad_changelog'


-- Table: ad_changelog

-- DROP TABLE ad_changelog;

CREATE TABLE ad_changelog
(
  ad_changelog_id numeric(10,0) NOT NULL,
  ad_session_id numeric(10,0) NOT NULL,
  ad_table_id numeric(10,0) NOT NULL,
  ad_column_id numeric(10,0) NOT NULL,
  ad_client_id numeric(10,0) NOT NULL,
  ad_org_id numeric(10,0) NOT NULL,
  isactive character(1) NOT NULL DEFAULT 'Y'::bpchar,
  created timestamp without time zone NOT NULL DEFAULT now(),
  createdby numeric(10,0) NOT NULL,
  updated timestamp without time zone NOT NULL DEFAULT now(),
  updatedby numeric(10,0) NOT NULL,
  record_id numeric(10,0) NOT NULL,
  oldvalue character varying(2000),
  newvalue character varying(2000),
  undo character(1),
  redo character(1),
  iscustomization character(1) NOT NULL DEFAULT 'N'::bpchar,
  trxname character varying(60),
  description character varying(255),
  eventchangelog character(1),
  CONSTRAINT ad_changelog_pkey PRIMARY KEY (ad_changelog_id , ad_session_id , ad_table_id , ad_column_id ),
  CONSTRAINT adcolumn_adchangelog FOREIGN KEY (ad_column_id)
      REFERENCES ad_column (ad_column_id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
  CONSTRAINT adsession_adchangelog FOREIGN KEY (ad_session_id)
      REFERENCES ad_session (ad_session_id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED,
  CONSTRAINT adtable_adchangelog FOREIGN KEY (ad_table_id)
      REFERENCES ad_table (ad_table_id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
  CONSTRAINT ad_changelog_isactive_check CHECK (isactive = ANY (ARRAY['Y'::bpchar, 'N'::bpchar])),
  CONSTRAINT ad_changelog_iscustomization_check CHECK (iscustomization = ANY (ARRAY['Y'::bpchar, 'N'::bpchar]))
)
WITH (
  OIDS=FALSE
);
ALTER TABLE ad_changelog
  OWNER TO adempiere;

-- Index: ad_changelog_speed

-- DROP INDEX ad_changelog_speed;

CREATE INDEX ad_changelog_speed
  ON ad_changelog
  USING btree
  (ad_table_id , record_id );

-- Function: symmetricds.sym_largeobject(oid)

-- DROP FUNCTION symmetricds.sym_largeobject(oid);

CREATE OR REPLACE FUNCTION symmetricds.sym_largeobject(objectid oid)
  RETURNS text AS
$BODY$                                                                                                                                            DECLARE                                                                                                                                                                                                  encodedBlob text;                                                                                                                                                                                      encodedBlobPage text;                                                                                                                                                                                BEGIN                                                                                                                                                                                                    encodedBlob := '';                                                                                                                                                                                     FOR encodedBlobPage IN SELECT pg_catalog.encode(data, 'escape')                                                                                                                                                   FROM pg_largeobject WHERE loid = objectId ORDER BY pageno LOOP                                                                                                                                           encodedBlob := encodedBlob || encodedBlobPage;                                                                                                                                                       END LOOP;                                                                                                                                                                                              RETURN pg_catalog.encode(pg_catalog.decode(encodedBlob, 'escape'), 'base64');                                                                                                                                              EXCEPTION WHEN OTHERS THEN                                                                                                                                                                               RETURN '';                                                                                                                                                                                           END                                                                                                                                                                                                    $BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;
ALTER FUNCTION symmetricds.sym_largeobject(oid)
  OWNER TO symmetricds;

-- Function: symmetricds.sym_node_disabled()

-- DROP FUNCTION symmetricds.sym_node_disabled();

CREATE OR REPLACE FUNCTION symmetricds.sym_node_disabled()
  RETURNS character varying AS
$BODY$                                                                                                                                                     DECLARE                                                                                                                                                                                                  nodeId VARCHAR(50);                                                                                                                                                                                  BEGIN                                                                                                                                                                                                    select current_setting('symmetric.node_disabled') into nodeId;                                                                                                                                         return nodeId;                                                                                                                                                                                       EXCEPTION WHEN OTHERS THEN                                                                                                                                                                               return '';                                                                                                                                                                                           END;                                                                                                                                                                                                   $BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;
ALTER FUNCTION symmetricds.sym_node_disabled()
  OWNER TO symmetricds;

-- Function: symmetricds.sym_triggers_disabled()

-- DROP FUNCTION symmetricds.sym_triggers_disabled();

CREATE OR REPLACE FUNCTION symmetricds.sym_triggers_disabled()
  RETURNS integer AS
$BODY$                                                                                                                                                     DECLARE                                                                                                                                                                                                  triggerDisabled INTEGER;                                                                                                                                                                             BEGIN                                                                                                                                                                                                    select current_setting('symmetric.triggers_disabled') into triggerDisabled;                                                                                                                            return triggerDisabled;                                                                                                                                                                              EXCEPTION WHEN OTHERS THEN                                                                                                                                                                               return 0;                                                                                                                                                                                            END;                                                                                                                                                                                                   $BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;
ALTER FUNCTION symmetricds.sym_triggers_disabled()
  OWNER TO symmetricds;



"Dejar un comentario es una forma de agradecimiento"

No hay comentarios:

Publicar un comentario