Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I cannot find definite information about how a debian package should behave whilst being removed. Should it remove the data? E.g. for mysql I read data is kept which sounds logical to me (using purge will remove all stuff).

But here I found the text:

The difference between remove and purge is that while remove only deletes data and executables, purge also deletes all configuration files in addition.

So, what is true?

Update As I want to package one for ElasticSearch I need to know what is expected.

share|improve this question
    
Related: How to Completely Remove a Package in Debian and of course the apt-get manpage. –  kce Jan 26 '12 at 17:24
add comment

3 Answers 3

up vote 4 down vote accepted

Neither purge or remove will delete the mysql datadir.. see example

root@mail:~# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 34
Server version: 5.1.41-3ubuntu12.10 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database so;
Query OK, 1 row affected (0.00 sec)

mysql> use so;
Database changed
mysql> CREATE TABLE example_autoincrement (
    ->          id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    ->          data VARCHAR(100)
    ->        );
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO example_autoincrement (data) VALUES ('Hello world');
Query OK, 1 row affected (0.00 sec)

mysql> Bye
root@mail:~# apt-get remove mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libnet-daemon-perl libdbi-perl libhtml-template-perl mysql-server-core-5.1 mysql-client-core-5.1 libdbd-mysql-perl libplrpc-perl mysql-server-5.1 mysql-client-5.1
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  mysql-server
0 upgraded, 0 newly installed, 1 to remove and 49 not upgraded.
After this operation, 131kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 52161 files and directories currently installed.)
Removing mysql-server ...
root@mail:~# ls /var/lib/mysql/
debian-5.1.flag  ibdata1  ib_logfile0  ib_logfile1  mail.pid  mysql  mysql_upgrade_info  so
root@mail:~# apt-get install mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  mysql-server
0 upgraded, 1 newly installed, 0 to remove and 49 not upgraded.
Need to get 94.8kB of archives.
After this operation, 131kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ lucid-updates/main mysql-server 5.1.41-3ubuntu12.10 [94.8kB]
Fetched 94.8kB in 0s (98.4kB/s)       
Selecting previously deselected package mysql-server.
(Reading database ... 52158 files and directories currently installed.)
Unpacking mysql-server (from .../mysql-server_5.1.41-3ubuntu12.10_all.deb) ...
Setting up mysql-server (5.1.41-3ubuntu12.10) ...
root@mail:~# /etc/init.d^C
root@mail:~# service mysql start
start: Job is already running: mysql
root@mail:~# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 35
Server version: 5.1.41-3ubuntu12.10 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| so                 |
+--------------------+
3 rows in set (0.00 sec)

mysql> Bye
root@mail:~# apt-get purge mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libnet-daemon-perl libdbi-perl libhtml-template-perl mysql-server-core-5.1 mysql-client-core-5.1 libdbd-mysql-perl libplrpc-perl mysql-server-5.1 mysql-client-5.1
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  mysql-server*
0 upgraded, 0 newly installed, 1 to remove and 49 not upgraded.
After this operation, 131kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 52161 files and directories currently installed.)
Removing mysql-server ...
root@mail:~# 
root@mail:~# 
root@mail:~# ls /var/lib/mysql/
debian-5.1.flag  ibdata1  ib_logfile0  ib_logfile1  mail.pid  mysql  mysql_upgrade_info  so
root@mail:~# 
share|improve this answer
    
hmmh, thanks + strange. What is recommended? please see edit –  Karussell Jan 26 '12 at 15:33
    
not sure what you want to do –  Mike Jan 26 '12 at 15:50
    
sorry if I was unclear. I would like to package ElasticSearch which comes with data and configuration. What is expected for debian users normally? I know that the configuration will stay but will the data always be preserved after remove? Is there a common sense or sth.? –  Karussell Jan 26 '12 at 16:45
    
yes you should always preserve data –  Mike Jan 26 '12 at 23:30
add comment

I think the "data" it is referring to is any nonexecutable resources shipped in the package, e.g. things found in /usr/share. Are you specifically concerned about mysql, or another package?

If data is valuable to you you should be backing it up anyway.

share|improve this answer
    
Do you know what is recommended as I want to know it for ElasticSearch packaging: github.com/elasticsearch/elasticsearch/issues/1525 –  Karussell Jan 26 '12 at 15:33
add comment

As I want to package one for ElasticSearch I need to know what is expected.

If I understand you correctly, you are in the process of packaging ElasticSearch as .deb for distribution.

If that is the case, and you are building a .deb package for public distribution I recommend you 1) fully read the relevant sections on packaging in the Debian Developer's Reference and ask on the appropriate Debian mailing-list (probably Debian-Developer).

Generally speaking, remove will just remove the binaries and libraries associated with a package while purge will remove the binaries, libraries, documentation, and configuration files. It is considered bad form for your package to nuke the user's data without at least informing them first.

I really suggest you check with an experienced Debian Maintainer before deciding how to proceed - especially if you want to submit this package to Debian repositories.

Another word of device: As a long-time Debian user, almost nothing annoys me more than a 3rd party distributing their software as a .deb that does follow standard Debian conventions. If you want to keep your users, please ensure that your package is well maintained and meets the guidelines as laid out by the Debian team.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.