RGPD - Delete call data records older than 6 month
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Xala 873428f12b
fix verbose problems
2 years ago
LICENSE Initial commit 2 years ago
README.md fix verbose problems 2 years ago
purge-cdr-rgpd.sh fix verbose problems 2 years ago

README.md

purge-cdr-rgpd

RGPD - Delete call data records older than 6 months

!! Temporary repository !!

Install

Copy this shell script wherever you want (i.e. /opt/)

Add execution rights

Configuration

Edit purge-cdr-rgpd.sh and set your SQL/API variables.

Usage

Note:

This script has no output except in case of errors. In debug mode, additional information is displayed.

Two modes

Silent mode (default):

% ./purge-cdr-rgpd.sh <DD/MM/YYYY>

Where <DD/MM/YYYY> is date format.

Debug mode:

% DEBUG=1 ./purge-cdr-rgpd.sh <DD/MM/YYYY>

Exemples

Delete CDR older than 20/10/2020:

% ./purge-cdr-rgpd.sh 20/10/2020

Delete CDR everyday in crontab with log file:

00 01 * * * unix-user /opt/purge-cdr-rgpd.sh $(date +"%D/%m/%Y) &> /var/log/purge-cdr-rgpd.log

Annexes

SQL scheme

CREATE DATABASE mytest;
GRANT ALL PRIVILEGES  ON mytest. * TO mytest@'%' ;
USE mytest;
CREATE TABLE `cdr` (
`id` bigint NOT NULL AUTO_INCREMENT,
`team_id` bigint DEFAULT  NULL ,
`call_start_time` timestamp NOT  NULL ,
`call_answered_time` timestamp NULL DEFAULT NULL ,
`call_hangup_time` timestamp NULL DEFAULT NULL ,
`from_number` var char ( 16 ) NOT NULL ,
`to_number` var char ( 16 ) NOT NULL ,
`duration` int (  11 ) DEFAULT  0 ,
`cost` int ( 11 ) NOT NULL DEFAULT  0 ,
`hangup_cause` varchar ( 32 ) DEFAULT NULL ,
`record_path` varchar ( 1024 ) DEFAULT NULL ,
PRIMARY KEY ( `id` ),
KEY `call_start_time` ( `call_start_time` )
} ENGINE =  InnoDB AUTO_INCREMENT =  1047970722 DEFAULT CHARSET = utf8;

API call

DELETE https://api.mytest.localhost/cdn/{filepath} HTTP/1.1
Authorization: {{token}}