इस ब्लॉग के पहले भाग में, जोनाथन ने बताया कि बर्मन-वाल-आर्काइव कमांड कैसे काम करता है। अब, यह मानते हुए कि आपने उन निर्देशों का पालन किया है, आपके पास एक ठीक से कॉन्फ़िगर किया गया PostgreSQL इंस्टेंस है और चल रहा है। इस दूसरे भाग में, मैं आपको दिखाऊंगा कि कैसे barman-cloud-backup आदेश काम करता है।
जैसा कि आप कमांड नाम से ही अनुमान लगा सकते हैं, barman-cloud-backup कमांड आपको सीधे PostgreSQL सर्वर से बैकअप निष्पादित करने और गंतव्य के रूप में क्लाउड में S3 संगत ऑब्जेक्ट स्टोर का उपयोग करने की अनुमति देता है।
example@sqldat.com:~ $ barman-cloud-backup --help
usage: barman-cloud-backup [-V] [--help] [-v | -q] [-P PROFILE] [-z | -j]
[-e {AES256,aws:kms}] [-t] [-h HOST] [-p PORT]
[-U USER] [--immediate-checkpoint] [-J JOBS]
[-S MAX_ARCHIVE_SIZE] [--endpoint-url ENDPOINT_URL]
destination_url server_name
This script can be used to perform a backup of a local PostgreSQL instance and
ship the resulting tarball(s) to the Cloud. Currently only AWS S3 is supported.
positional arguments:
destination_url URL of the cloud destination, such as a bucket in AWS
S3. For example: `s3://bucket/path/to/folder`.
server_name the name of the server as configured in Barman.
optional arguments:
-V, --version show program's version number and exit
--help show this help message and exit
-v, --verbose increase output verbosity (e.g., -vv is more than -v)
-q, --quiet decrease output verbosity (e.g., -qq is less than -q)
-P PROFILE, --profile PROFILE
profile name (e.g. INI section in AWS credentials
file)
-z, --gzip gzip-compress the WAL while uploading to the cloud
-j, --bzip2 bzip2-compress the WAL while uploading to the cloud
-e {AES256,aws:kms}, --encryption {AES256,aws:kms}
Enable server-side encryption for the transfer.
Allowed values: 'AES256'|'aws:kms'.
-t, --test Test cloud connectivity and exit
-h HOST, --host HOST host or Unix socket for PostgreSQL connection
(default: libpq settings)
-p PORT, --port PORT port for PostgreSQL connection (default: libpq
settings)
-U USER, --user USER user name for PostgreSQL connection (default: libpq
settings)
--immediate-checkpoint
forces the initial checkpoint to be done as quickly as
possible
-J JOBS, --jobs JOBS number of subprocesses to upload data to S3 (default:
2)
-S MAX_ARCHIVE_SIZE, --max-archive-size MAX_ARCHIVE_SIZE
maximum size of an archive when uploading to S3
(default: 100GB)
--endpoint-url ENDPOINT_URL
Override default S3 endpoint URL with the given one
अब जब हमारे पास कमांड और उसके विकल्पों के बारे में स्पष्ट जानकारी है, तो हम अपना पहला क्लाउड बैकअप निष्पादित करने के लिए तैयार हैं:
example@sqldat.com:~ $ barman-cloud-backup -P barman-cloud \ -e AES256 -j --immediate-checkpoint -J 4 \ s3://barman-s3-test/ pg12
एक बार बैकअप सफलतापूर्वक पूरा हो जाने के बाद, base बैकअप वाली निर्देशिका आपके S3 बकेट में होगी। आइए इसे जांचें, सर्वर नाम और base . के साथ गंतव्य पथ का निर्माण करें निर्देशिका:
example@sqldat.com:~ $ aws s3 --profile barman-cloud ls s3://barman-s3-test/pg12/base/
PRE 20200713T120856/
वैकल्पिक रूप से, आप barman-cloud-backup-list . का उपयोग कर सकते हैं , लेकिन इस लेख में मैं इसके पीछे के यांत्रिकी पर ध्यान देना चाहूंगा।
20200711T092548 निर्देशिका में बैकअप से संबंधित सभी फाइलें हैं जिन्हें हमने अभी निष्पादित किया है। आइए इसकी सामग्री देखें:
example@sqldat.com:~ $ aws s3 --profile barman-cloud ls s3://barman-s3-test/pg12/base/20200713T120856/ 2020-07-13 12:09:08 1138 backup.info 2020-07-13 12:09:07 9263096 data.tar.bz2
जैसा कि हम देख सकते हैं, हमारे बैकअप वाली एक संपीड़ित और एन्क्रिप्टेड फ़ाइल है (data.tar.bz2 ) और एक फ़ाइल जिसे backup.info . कहा जाता है जिसमें बैकअप से संबंधित जानकारी होती है। हम data.tar.bz2 . को कॉपी और अनज़िप करके बैकअप को पुनर्स्थापित कर सकते हैं हमारे स्थानीय सर्वर पर फ़ाइल जैसा कि नीचे दिखाया गया है:
example@sqldat.com:~ $ aws s3 --profile barman-cloud cp s3://barman-s3-test/pg12/base/20200713T120856/data.tar.bz2 restore-dir download: s3://barman-s3-test/pg12/base/20200713T120856/data.tar.bz2 to restore-dir/data.tar.bz2 example@sqldat.com:~ $ cd restore-dir example@sqldat.com:~/restore-dir $ tar xjvf data.tar.bz2 example@sqldat.com:~/restore-dir $ ls PG_VERSION conf.d pg_commit_ts pg_ident.conf pg_notify pg_snapshots pg_subtrans pg_wal postgresql.conf backup_label data.tar.bz2 pg_dynshmem pg_logical pg_replslot pg_stat pg_tblspc pg_xact base global pg_hba.conf pg_multixact pg_serial pg_stat_tmp pg_twophase postgresql.auto.conf
महान! जैसा कि हम देख सकते हैं, PostgreSQL इंस्टेंस के DATADIR में सभी फ़ाइलें जिनका हमने बैकअप लिया है, कॉन्फ़िगरेशन फ़ाइलों सहित, यहाँ सही ढंग से सूचीबद्ध हैं।
निष्कर्ष
barman-cloud-backup के साथ कमांड बर्मन एक महत्वपूर्ण विशेषता का परिचय देता है जो आपको स्थानीय पोस्टग्रेएसक्यूएल सर्वर से क्लाउड ऑब्जेक्ट स्टोरेज सेवाओं के लिए बेस बैकअप को निष्पादित करने और सीधे शिप करने की अनुमति देता है जो कि कुछ सरल चरणों में एडब्ल्यूएस एस 3 के साथ संगत हैं। यह एन्क्रिप्शन, समानांतर अपलोड, संपीड़न का समर्थन करता है, और आपके स्थानीय सर्वर पर डिस्क स्थान को बचाने और बैकअप को क्लाउड पर सुरक्षित रूप से स्थानांतरित करने की अनुमति देता है।
Barman 2.11 के रिलीज के साथ , जो कुछ दिन पहले हुआ था, महत्वपूर्ण नई सुविधाएँ पेश की गई हैं, जिनमें barman-cloud-wal-restore शामिल हैं। और barman-cloud-restore कमांड, जो AWS S3 जैसे ऑब्जेक्ट स्टोर से बैकअप और WAL फ़ाइलों को पुनः प्राप्त करने की अनुमति देता है। इस संबंध में, हम जल्द ही एक नया ब्लॉग लेख प्रकाशित करेंगे जिसमें बताया जाएगा कि इन कमांड का उपयोग करके PostgreSQL इंस्टेंस की पुनर्प्राप्ति कैसे तैयार की जाए। बने रहें।