Snippets tagged "debian sysadmin"
Mailer un backup mysql comme attachement en ligne de commande
On va utiliser mutt :
$ sudo apt-get install mutt
La commande (cronable) :
$ mysqldump -uroot -p --all-databases --opt \
| bzip2 > /path/to/backup/export.sql.bz2 \
&& echo "En date du " `date` \
| mutt -s "[Nikobox] Backup MySQL total du `date | awk '{ print $2,$3,$4}'`" \
-a /path/to/backup/export.sql.bz2 you@fai.com
Exclure un paquet d'un dist-upgrade
Wajig permet de bloquer un paquet via sa sous-commande hold :
$ sudo apt-get install wajig
$ sudo wajig hold <package_name>
$ sudo apt-get update
$ sudo apt-get dist-upgrade
Ici le paquet <package_name> ne sera pas mis à jour.
Avec aptitude, vous pouvez conserver un paquet en faisant :
$ aptitude hold package_name
et enlever le drapeau « hold » avec
$ aptitude unhold package_name
Turn on Bash Smart Completion
Just edit /etc/bash.bashrc
Uncomment the following lines, by removing the # in the beginning of the lines:
#if [ -f /etc/bash_completion ]; then # . /etc/bash_completion #fi
Now, resource the modified file :
$ source /etc/bash.bashrc
Then try to tape apt-cache [TAB][TAB]
You will have this result in replacement of the habitual list of files and directories of your current path :
$ apt-cache
add dotty dumpavail pkgnames rdepends show showsrc unmet
depends dump gencaches policy search showpkg stats xvcg
It works with a lot of functions like cd (it will provide only directories), apt-get,...
It also enable code completion when using the sudo command.
Isn't it useful ?
Nota : The tip I give here is to activate Smart Completion for all users. If you want to activate it for only one user (or if you want to activate it but doesn't have write rights to /etc/bash.bashrc) you can modify your ~/.bashrc file and uncomment the same lines as described upper and resource it with
$ source ~/.bashrc
Downgrader un package sous Ubuntu
On peut forcer la version d'un paquet à installer :
$ sudo aptitude install nomdupaquet=1.2.3-version2
Exporter et réimporter la liste des paquets installés
Genre pour reproduire la config d'un ancien serveur vers un nouveau serveur.
Export :
$ sudo dpkg --get-selections > selections.txt
Réimportation :
$ sudo dpkg --set-selections < selections.txt
Réinstallation des paquets :
$ sudo apt-get dselect-upgrade
