ParsX.com
پذیرش پروژه از دانشجویی ... تا سازمانی 09376225339
 
   ProfileProfile   Log in to check your private messagesLog in to check your private messages  |  FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups Log inLog in   RegisterRegister 

postgresql schedule backup

 
Post new topic   Reply to topic    ParsX.com Forum Index -> مفاهيم اوليه سيستم عامل / Linux
View previous topic :: View next topic  
Author Message
vahid
بي تو هرگز


Joined: 26 Nov 2004
Posts: 3067
Location: Tehran

PostPosted: Wed Dec 13, 2023 10:13 am    Post subject: postgresql schedule backup Reply with quote

To perform a backup with this utility, just call it and specify the destination file:
su - postgres
pg_dump -U postgres db_name | gzip > backup_file.gz

You can add a cron job to run backups regularly. To this end, follow the steps below:

        Create a backup storage folder
        sudo mkdir -p /backups/postgresql
        Provide the postgres user permissions to the directory
        sudo chown postgres /backups/postgresql
        Set the PostgreSQL user
        su - postgres
        Open crontab by running the command
        crontab -e
        Add this line at the end, replacing db_name with the name of your database
        0 0 * * 0 pg_dump -U postgres db_name | gzip > /backups/postgresql/db_name\_`date +20\%y\%m\%d`.gz.gz

This way, a backup will be performed on your server at midnight on Saturday. This is the most basic solution to a backup task.


https://sqlbak.com/blog/how-to-automate-postgresql-database-backups-in-linux/
Back to top
Display posts from previous:   
Post new topic   Reply to topic    ParsX.com Forum Index -> مفاهيم اوليه سيستم عامل / Linux All times are GMT + 3.5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum