How To Move a PostgreSQL Data Directory to a New Location on Ubuntu 22.04

The examples throughout this tutorial will involve moving the data to a block storage device mounted at /mnt/volume_nyc1_01. If you’re using Block Storage on DigitalOcean, read our documentation on How to Create and Set Up Volumes for Use with Droplets to guide you on mounting your volume before continuing with this tutorial.

Regardless of what underlying storage you use, though, the following steps can help you move the data directory to a new location.

Step 1 — Moving the PostgreSQL Data Directory

Before we get started with moving PostgreSQL’s data directory, let’s verify the current location by starting an interactive PostgreSQL session. In the following command, psql is the command to enter the interactive monitor and -u postgres tells sudo to execute psql as the system’s postgres user:

sudo -u postgres psql

Copy

Once you have the PostgreSQL prompt opened up, use the following command to show the current data directory:

SHOW data_directory;

Copy

Output       data_directory
-----------------------------
 /var/lib/postgresql/14/main
(1 row)

This output confirms that PostgreSQL is configured to use the default data directory, /var/lib/postgresql/14/main, so that’s the directory you need to move. Once you’ve confirmed the directory on your system, you can close the psql prompt by running the \q meta-command:

\q

Copy

To ensure the integrity of the data, stop PostgreSQL before you actually make changes to the data directory:

sudo systemctl stop postgresql

Copy

systemctl doesn’t display the outcome of all service management commands. To verify that you’ve successfully stopped the service, use the following command:

sudo systemctl status postgresql

Copy

The output should tell you that PostgreSQL is inactive (dead), meaning it has been stopped:

Output○ postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor>
     Active: inactive (dead) since Thu 2022-06-30 18:46:35 UTC; 27s ago
    Process: 4588 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
   Main PID: 4588 (code=exited, status=0/SUCCESS)
        CPU: 1ms

Now that the PostgreSQL server is no longer running, copy the existing database directory to the new location with rsync. Using the -a flag preserves the permissions and other directory properties, while -v provides verbose output to help you follow the progress. You’re going to start the rsync from the postgresql directory in order to mimic the original directory structure in the new location. By creating that postgresql directory within the mount-point directory and retaining ownership by the PostgreSQL user, you can avoid permissions problems for future upgrades.

Note: Be sure there is no trailing slash on the directory, which may be added if you use TAB completion. If you do include a trailing slash, rsync will dump the contents of the directory into the mount point instead of copying over the directory itself.

The version directory, 14, isn’t strictly necessary since you’ve defined the location explicitly in the postgresql.conf file, but following the project convention certainly won’t hurt, especially if there’s a need in the future to run multiple versions of PostgreSQL:

sudo rsync -av /var/lib/postgresql /mnt/volume_nyc1_01

Copy

Once the copy is complete, rename the current folder with a .bak extension and keep it until you’ve confirmed that the move was successful. This will help to avoid confusion that could arise from having similarly-named directories in both the new and the old location:

sudo mv /var/lib/postgresql/14/main /var/lib/postgresql/14/main.bak

Copy

Now you’re ready to configure PostgreSQL to access the data directory in its new location.

Step 2 — Pointing to the New Data Location

By default, the data_directory configuration directive is set to /var/lib/postgresql/14/main in the /etc/postgresql/14/main/postgresql.conf file. Edit this file to reflect the new data directory:

sudo nano /etc/postgresql/14/main/postgresql.conf

Copy

Find the line that begins with data_directory and change the path which follows to reflect the new location. In the context of this tutorial, the updated directive will be written as:

/etc/postgresql/14/main/postgresql.conf

. . .
data_directory = '/mnt/volume_nyc1_01/postgresql/14/main'
. . .

Save and close the file by pressing CTRL + XY, then ENTER. This is all you need to do to configure PostgreSQL to use the new data directory location. All that’s left at this point is to start the PostgreSQL service again and check that it is indeed pointing to the correct data directory.

Step 3 — Restarting PostgreSQL

After changing the data-directory directive in the postgresql.conf file, go ahead and start the PostgreSQL server using systemctl:

sudo systemctl start postgresql

Copy

To confirm that the PostgreSQL server started successfully, check its status by again using systemctl:

sudo systemctl status postgresql

Copy

If the service started correctly, the Active line will say active (exited) in the command’s output:

Output● postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor>
     Active: active (exited) since Thu 2022-06-30 18:50:18 UTC; 3s ago
    Process: 4852 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
   Main PID: 4852 (code=exited, status=0/SUCCESS)
        CPU: 1ms

Lastly, to make sure that the new data directory is indeed in use, open the PostgreSQL command prompt:

sudo -u postgres psql

Copy

Check the value for the data directory again:

SHOW data_directory;

Copy

Output             data_directory
----------------------------------------
 /mnt/volume_nyc1_01/postgresql/14/main
(1 row)

This confirms that PostgreSQL is using the new data directory location. Following this, take a moment to ensure that you’re able to access your database as well as interact with the data within. Once you’ve verified the integrity of any existing data, you can remove the backup data directory:

sudo rm -Rf /var/lib/postgresql/14/main.bak

Copy

With that, you have successfully moved your PostgreSQL data directory to a new location.

2 thoughts on “How To Move a PostgreSQL Data Directory to a New Location on Ubuntu 22.04

  1. They additionally tend to be free of iron and copper, since males need decrease amounts of these
    vitamins than ladies. Our prime natural steroids to build muscle (Demetria) choice — Backyard of Life Organics Men’s Once Every Day — is probably one of the few certified organic multivitamins on the
    market and some of the comprehensive. We also recognize
    the company’s commitment to quality, with nutrients sourced from entire food components quite than synthetically made ones.

    According to the company, merchandise are third-party examined for
    purity and potency, so you’ll find a way to rest assured that the contents match the label.
    In Canada, responsible TRT providers emphasize personalised care plans
    and ongoing medical supervision to reduce risk.
    This approach ensures remedy is adjusted to fit your body—not simply your lab results.

    Testosterone is a crucial hormone that supports muscle progress, bone density, purple
    blood cell manufacturing, temper stability, and sexual operate.

    In men with low testosterone, testosterone replacement therapy (TRT) helps restore these levels to a wholesome vary.

    TRT works by introducing exterior testosterone into the body—through injections, gels, or patches—which dietary supplements what the
    body is not producing adequately. These online TRT clinics let you seek the assistance of with a medical professional, get your blood work done, and obtain your testosterone remedy all
    from the comfort of your own home. A easy blood take a look at can present essential information about hormone ranges, facilitating personalised treatment plans based mostly on individual results and medical presentation. If you’re unclear about whether testosterone remedy is
    best for you, attempt Hone Well Being.
    Online Testosterone alternative therapy is a medical treatment prescribed by
    medical doctors to assist men with low testosterone levels.
    Selecting between a neighborhood in-person clinic and a web-based doctor for
    TRT therapy is a private determination that is determined by varied components, including
    your lifestyle, medical wants, and preferences. Both options supply
    viable pathways to reclaiming your vitality and enhancing
    your quality of life. Some of those signs and symptoms could
    be brought on by different elements, including medication unwanted aspect
    effects, obstructive sleep apnea, thyroid problems, diabetes and depression.
    It Is additionally attainable that these circumstances
    trigger low testosterone ranges, so remedy may result in increase of testosterone levels.
    For example, if you journey incessantly, injections
    may be more sensible than lotions, which require consistent every day utility.

    On the opposite hand, pellets might be a better fit for individuals with a stable routine who wish to
    avoid the hassle of frequent dosing.
    Gradual absorption causes more stable testosterone levels within the blood.
    Testosterone propionate has a considerably shorter half-life compared
    to other cypionate and different testosterone esters – just 20 hours.
    Propionate and cypionate have similar effectiveness, dangers and toxicity.

    Alex skilled important improvements in his libido and
    general well-being inside a number of months.
    Testosterone remedy might help reverse the results of hypogonadism, but it’s unclear whether or not testosterone therapy would profit
    older men who’re otherwise healthy. Hypogonadism hampers the ability
    to produce normal quantities of testosterone due to a problem with the testicles or with the pituitary gland that controls the testicles.
    Testosterone substitute remedy, in the form of injections, pellets, patches or gels, can enhance the indicators and symptoms of low testosterone in these men. Considering testosterone remedy to assist you
    feel younger and more vigorous as you age? Testosterone
    lotions or gels are utilized directly to the
    pores and skin, the place they’re absorbed into the bloodstream.

    Collectively, Pearlman and Tatem demystify testosterone therapy,
    positioning it not simply as a treatment—but
    as a critical device for enhancing longevity, independence, and
    quality of life. Prostate most cancers wants testosterone to develop,
    therefore taking TRT may make the most cancers cells grow
    faster. The National Cancer Analysis Institute states that males with greater levels
    of testosterone in their blood usually tend to be recognized with prostate cancer.
    TRT, or androgen substitute therapy (ART), is
    a therapy that doctors give to males with testosterone deficiency who show symptoms
    of hypogonadism.
    Formulyst Lifting and Wrinkle Smoothing CreamThis deeply nourishing cream was
    designed to assist reclaim a youthful-looking complexion. Formulyst’s Lifting and Wrinkle Smoothing
    Cream is a true multitasker. It helps lift, easy, and refine the looks and tone of the skin. The velvety formulation incorporates a robust blend of lipids and botanicals that have focused anti-aging
    benefits. In Canada, TRT clinics usually present structured follow-ups,
    ongoing lab testing, and skilled guidance to assist men preserve long-term hormone steadiness and avoid unnecessary problems.
    Some males report mood swings, irritability, or a short mood, especially within the initial weeks of remedy.
    A smaller quantity could notice elevated aggression or restlessness.

    It’s necessary to observe for signs when taking any probiotic complement.
    All Now Foods probiotics are CGMP certified, guaranteeing that
    high quality control measures are followed. In addition, the products are certified by Underwriters Laboratories, a
    good group that requires strict security, quality, and security standards.

    This probiotic is third-party tested, and the corporate conducts extensive testing of its own for allergens, pesticides, heavy metals, and more to
    ensure the best safety and quality standards. If you’re looking for a high-quality, third-party-tested probiotic and your diet
    lacks fiber, Seed DS-01 Daily Synbiotic could also be a wise choice.
    This complement blends fifty three.6 energetic fluorescent models (AFUs) of clinically studied probiotic strains with prebiotics, beneficial fibers which may be
    a primary fuel source for the probiotic micro organism.
    Pink blood cell counts had been taken from the people on a yearly foundation and outcomes
    confirmed an increase of 10% after the first year and 38% after 10 years.
    Individuals who’ve a high purple blood cell rely and thrombophilia should avoid taking TRT.
    TRT can enhance red blood cell rely which in flip will increase blood viscosity.
    Hypercapnia is a situation the place carbon dioxide ranges get too high in the blood.
    This can lead to issues such as respiratory acidosis, with signs
    together with fatigue and drowsiness or a strong want to sleep.

  2. Eine Hypothese besagt, dass entsprechende mit dem Gen ausgestattete Personen zu einer
    besseren Nährstoffverteilung neigen. Andere wiederum, die genetisch anders ausgestattet sind, legen nicht so schnell zu.

    Und wir alle kennen diese Idee, dass ein Bekannter essen kann, wie er will, und nicht zulegt,
    jemand anders sieht einen Kuchen nur an und bekommt eine Speckrolle.
    Pima Indianer, die in Mexico leben, sind generell weit weniger fett als
    diejenigen ihres Stammes, die in Amerika leben. Und wie bereits vorher
    erwähnt, gibt es Gene, die die Aktivität eines Menschen beim überfüttern in die Höhe schnellen lassen. Diese Aktivität nennen wir NEAT,
    Non-Exercise Activity Thermogenesis.
    Zunächst sollten die Testergebnisse mit einem Experten für Ernährung oder Genetik besprochen werden. Dies stellt sicher,
    dass die gewonnenen Erkenntnisse korrekt interpretiert werden. In vielen Fällen beinhalten die Berichte Hinweise
    auf bevorzugte Nahrungsmittelgruppen, die entweder verstärkt
    konsumiert oder gemieden werden sollten. Ein praktisches
    Beispiel könnte eine Empfehlung sein, Omega-3-Fettsäuren aus Fisch oder
    Pflanzenölen vermehrt in den Speiseplan aufzunehmen, wenn der Körper genetisch bedingt Schwierigkeiten hat, diese selbst zu synthetisieren.
    Unsere Gentests analysieren Deine DNA und müssen nur einmal im Leben durchgeführt werden. Dabei werden bis zu a hundred genetische Varianten von bis zu 60 Genen bewertet.
    Wir machen Sie darauf aufmerksam, dass die Befüllung des Bewertungsbalkens, insbesondere in Bereichen mit wenigen genetischen Varianten, durch kleine
    Variationen im Beitrag der einzelnen genetischen Varianten beeinflusst werden kann.

    Basierend auf den Ergebnissen dieser Analysen können Experten oder spezialisierte Plattformen einen maßgeschneiderten Ernährungsplan erstellen. Ein solcher Plan berücksichtigt persönliche
    Präferenzen, aber vor allem die genetischen Voraussetzungen. Personalisierte Ernährung ist dabei keine allgemeine Empfehlung, sondern ein individueller Weg, um Gesundheit und Wohlbefinden nachhaltig zu
    fördern. Die Kombination von MyNutriGenes und MyFitnessGenes bietet dir ein umfassendes Bild deiner Gesundheit und Fitness.
    Diese beiden Exams ergänzen sich optimal und
    zeigen dir, wie du deine Leistung steigern und deinen Körper richtig versorgen kannst.
    Nur bei den „Koffeingenen” gibt es kleine
    Überschneidungen. Mit MyNutriGenes findest du heraus, welche Nährstoffe dein Körper wirklich braucht.

    Daher ist es wichtig, einen DNA-Test für Sportler zu machen, wie wir ihn Ihnen mit dem tellmeGen Starter DNA-Kit anbieten. Die von 24Genetics bereitgestellten genetischen Informationen sind nur für Forschungs-, Informations- und Bildungszwecke gültig.
    In keinem Fall sind sie für den klinischen oder diagnostischen Gebrauch gültig.
    Dieser Dienst ist auf dermatologische Kliniken spezialisiert.
    Zugang und Konsultation von genetische Daten, die für Gesundheit und Pharmakologie
    related sind.
    Wir wissen, wie Ihre Muskelregeneration nach dem Coaching aussieht.
    Alternatives and challenges in nutrigenetics/nutrigenomics and health.
    Bei Anbietern, bei denen medizinische Aussagen (z.B.
    über Krankheiten) gemacht werden, muss ein Arzt dieser zustimmen. Der Apothekerverband fordert jedoch,
    dies künftig auch zu dürfen. Sofern es «nur» um Abstammung geht
    oder allgemeine Aussagen zu Trainings- oder Ernährungstyp gemacht werden, geht eine Bestellung auch ohne.

    Mehrere Gene in Verbindung mit der Umwelt tragen zur
    Herausbildung des betreffenden Merkmals bei. In diesem Kontext kommt es darauf an, ein Berechnungsmodell zu
    verwenden, das alle individuellen Beiträge jeder genetischen Variante berücksichtigt (polygener Effekt).
    Das Ergebnis der rechnerischen Auswertung ist
    ein Bewertungsmodell, das in diesem Bericht durch einen mehr oder weniger ausgefüllten Balken dargestellt wird.

    Der firmeneigene Algorithmus von HeartGenetics
    erstellt das Bewertungsmodell auf der Grundlage einer Vielzahl von Variablen, d.
    Das Ergebnis des Bewertungsmodells ist wichtiger als
    die Anzahl der Gene, die möglicherweise als verändert gekennzeichnet werden. Keine genetische Variante
    sollte einzeln interpretiert werden. Der Bereich der Vitamine bildet eine Ausnahme,
    da mehrere Gene zu mehreren Vitaminen beitragen.
    Studien an Zwillingen aber auch Adoptionsstudien zeigen uns allerdings, dass dieser Zusammenhang oftmals
    in sich zusammen fällt. Die Neigung dazu, mehr zu essen, ist somit ebenso
    vererbbar wie unsere Reaktion darauf. Bei den im Studio
    angebotenen Direct to Consumer Gentests wird meist eine Speichelprobe entnommen und in ein Labor gesendet.

    Daraufhin bekommt der Käufer eine Liste seiner
    Genvarianten und das Begleitpapier begründet dann, warum das nun bedeutet, dass man auf eine bestimmte Weise nun essen oder trainieren sollte.
    Seit ich die genetische Analyse bei mir durchgeführt
    habe, weiß ich nicht nur, warum ich in bestimmten Situationen beim
    Laufen erschöpft bin.
    Du bist die einzige Particular Person, die die Testergebnisse kennt, indem du unsere Ergebnisse verschlüsselt per E-Mail oder per
    Post erhältst. Wenn Sie wissen, für welche sportlichen Aktivitäten Sie aufgrund Ihrer genetischen Veranlagung besonders prädisponiert sind,
    können Sie Ihre Trainingsroutine optimal planen. Wenn wir von Umweltfaktoren sprechen, meinen wir alle Faktoren, die außerhalb Ihrer Genetik
    liegen und Ihre Gesundheit und damit auch Ihre sportliche Leistung beeinflussen können, d.
    Von der Temperatur oder Feuchtigkeit des Ortes, an dem Sie
    Ihren Sport ausüben, bis hin zu sozialen oder erzieherischen Variablen. Die genetischen Faktoren, die die sportliche Leistung beeinflussen, sind jedem Athleten eigen, d.
    Sie sind Teil seiner Biologie, unabhängig von seinem Trainingsniveau.

    Das Resultat erfolgt dann einige Wochen später through E-Mail oder
    über eine eigene App der Dienstleister. Um bestmögliche und präzise
    Resultate zu erhalten, sollten MyWellnessGenes und MyFitnessGenes separat bestellt
    werden. So vermeidest du Überschneidungen und erhältst klare Antworten auf deine spezifischen Fragen zur Gesundheit und Fitness.

    Ich bin froh diesen Geneventure-Test durchgeführt zu haben. In der Zukunft werde ich bei der Einnahme von Medikamenten mein persönliches genetisches Potential in jedem Fall
    beachten.

    References:

    testosteron präparate rezeptfrei – Ferdinand

Leave a Reply

Your email address will not be published. Required fields are marked *

RELATED POST

How to automatically restart Linux services with Systemd

Getting your Linux deployments working reliably is of paramount concern for production applications. One way to guarantee that a service…

How to Install SFTPGo on Ubuntu 22.04

Setup UFW Firewall For security reasons, it is recommended to install and configure the UFW firewall in your system. First,…

Executing Bash Scripts at Startup in Ubuntu Linux

Creating a Bash script in Ubuntu To create a Bash script in Ubuntu, you can use any text editor of…

How To Clear PHP’s Opcache

PHP can be configured to store precompiled bytecode in shared memory, called Opcache. It prevents the loading and parsing of PHP…