Обсуждение: check files .backup
Do you know if exist a function to check my file.backup created by pgdump. ?<br /><br />thnks<br /><br /><br /><br />
On 25/01/11 08:18, manuel antonio ochoa wrote: > Do you know if exist a function to check my file.backup created by > pgdump. ? What do you want to check? That it restores correctly? That it's complete and not truncated? That it hasn't been modified since being originally written? That it matches the data currently in the database? What? -- System & Network Administrator POST Newspapers
On Mon, Jan 24, 2011 at 5:18 PM, manuel antonio ochoa <manuel8aalfaro@gmail.com> wrote: > Do you know if exist a function to check my file.backup created by pgdump. I run backups like this in bash: if (pg_dump yadayada); then echo "backup succeeded." else echo "backup failed." fi; in a cronjob set to email me. Then when it fails or not, I see it right there in my nightly email.
On 01/25/2011 11:14 PM, manuel antonio ochoa wrote: > I would like it complete and not truncated? That it hasn't been modified > since being > originally written? OK. First, check the exit code from pg_backup so you detect any failures. The exit code is reported by the shell on UNIX systems in the $? variable, but you can usually just do something like the following (untested): if ! pg_backup .... ; then logger -p crit "pg_backup failed" mail -s "Pg backup failed" someone@yourcompany <<__END__ The latest backup failed. Check the logs for why, and fix it! __END__ fi Second: after writing the backup, calculate an md5sum or (preferably) digitally sign the backup using gpg. An md5sum is only really protection against corruption unless you store it somewhere separate and secure. I prefer to digitally sign my backups with detached gpg signatures. -- Craig Ringer