Maxime Chambreuil

Monday July 2, 2007

Administration

Max @ 22:04 | Filed under: Information Technology

GNU/LinuxHow to add a user to an existing group ?

$ adduser -g group -d /home/group/user user

How to create a block device from a file ?

For a 100M size file:

$ dd if=/dev/zero of=/root/block1 bs=100M count=1
$ losetup /dev/loop0 /root/block1
$ mkfs -j /dev/loop0
$ mount -t ext3 /dev/loop0 /mnt/newfs

How do I do an automatic backup ?

#!/bin/bash

cd /over/the/repository/to/backup
date +%d-%m-%Y > date
tar -zcvf /repository/for/backup/`head date`.tgz /repository/to/backup
rm date

How do I do an automatic dump ?

For PostgreSQL database :

#!/bin/bash

cd /repository/for/dumpfile
date +%d-%m-%Y > date
pg_dump -D database -U username > `head date`.database.sql
rm date

The password will be asked at the prompt, which is a problem I have never solved yet.

For MySQL database :

#!/bin/bash

cd /repository/for/dumpfile
date +%d-%md%Y > date
mysqldump -D database -u username -p passwd > `head date`.database.sql
rm date

You can copy these lines in a file, and move it to /etc/cron.daily/, for example.

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Copyright © Maxime Chambreuil