Skip to Content
Menu
This question has been flagged
2 Replies
6494 Views

Hello guy!

All by backup system is great here. But it miss one thing... How could I erase my oldest databases with my script? Which system do you use?

For the moment, I can delete database easily with (example) :

/usr/bin/dropdb  -U "odoo" odoo_quotidien_01-12-2014_17:00:01 2>>/home/flooder/Programmes/log/clean-databases-pt.log

All my databases names are in the form (with the date in):       

odoo_quotidien_01-12-2014_17:00:01

odoo_quotidien_02-12-2014_17:00:01

...

Thanks for youtr tips!

Avatar
Discard
Best Answer

You should script a bash script for this. I assume you always place the dumps in the same folder. Create a bash script that automaticly checks all files in the directory and let it remove the oldest (or for example dumps older than xx days)

A great example: https://wiki.postgresql.org/wiki/Automated_Backup_on_Linux 
Also have a look at this script: https://www.odoo.com/nl_NL/forum/help-1/question/how-do-i-automate-database-backups-8899
You can customize this as you wish. On a specific date, looping over them, creating a new one every xx time etc.

Update: If you also want to drop the db's / schema's from your postgreSQL you should look at the dropdb and drop schema commands. For example: http://www.postgresql.org/docs/9.4/static/sql-dropschema.html

Update #2

I've created a module which automatically does all this and is integrated in Odoo (V8).Have a look at my guide/topic about it here.

Avatar
Discard
Author

For the dump files, i'm ok. I can clean the oldest files. Now I want to delete ALSO the DATABASES. When I export to dump file, I also create a new database with it automatically. Now I have 200 databases and I want to clean it. Thanks

You should then look at the dropdb and drop schema command (http://www.postgresql.org/docs/9.4/static/sql-dropschema.html for example)

Nice solution

Best Answer

My suggestion, if your system Debian or Ubuntu, install module autopostgresqlbackup:

sudo apt-get update
sudo apt-get install autopostgresqlbackup

This is the best tools for me. This create, auto and hot: latest, daily, weekly and monthly backup with rotation, triggered by cron.

Avatar
Discard
Related Posts Replies Views Activity
1
Mar 15
10704
1
Mar 24
1677
2
Jan 24
1775
5
Aug 24
14914
1
Mar 15
3783