Archive

Archive for the ‘sysadmin’ Category

Backup/Copy mysql or mariadb database

March 19, 2016 Leave a comment

You can copy or backup all your databases with these commands including
coping to another server.

# backup
mysqldump -u root -p yourdb > mysqlbak.sql
or for dumping all databases
mysqldump –all-databases -u root -p > mysqlbakall.sql
# restore
mysql -u root -p yourdb < mysqlbak.sql
to restore all databases
mysql -u root -p < mysqlbakall.sql

Categories: sysadmin

Cloning mikrotik routerboard (rb7xx, rb9xx, rb11xxx)

February 1, 2016 Leave a comment

You can easily clone like routerboard hardware with these commands:

First to ssh admin@youripaddress or run terminal from winbox and run the following on the device you want to clone in this example we clone an rb751g to rb951.

## on rb751g type:
/export compact file=name

Then copy the name.rsc file to the rb951 $$either drag and drop it to files with winbox or use sftp.

hard reset the device you want to clone to by powering off and holding reset button, powering on,
and releasing reset button when led next to power plug starts to rapidly flash. Wait until the
os initializes and access with winbox.

## on rb951 type (after hard reset):
/import name.rsc ## you should see no errors.

## then on rb951 type:
/system reset run-after-reset=”name.rsc”
This will clear the current config and import the one from the rb751g

After a minute to load or so you should be able to access the rb951 with winbox and have a complete clone
of the rb751g.

Categories: sysadmin

Install libguestfs-tools and add serial console access to your vm

November 13, 2015 Leave a comment

To add serial access to your vm, with Debian/Ubuntu apt-get install libguestfs-tools.
Then with vm shutdown, execute the following:

root:~# guestmount -d vmname -i /mnt
root:~# ln -s /mnt/lib/systemd/system/getty@.service /mnt/etc/systemd/system
/getty.target.wants/getty@ttyS0.service
root:~# umount /mnt

Reboot your vm and you should have serial console access.

Categories: sysadmin

backup your kvm vm with dd

September 19, 2015 Leave a comment

The dd utility is a good way to make a backup of your kvm vm image. It
is nice to have a progress indicator so install pv (pipe viewer) to
gain this feature ..ie apt-get install pv.

Here is a backup script:

dd if=org.img | pv | dd of=backup.img bs=1M

On my system it took about 10 minutes to complete a backup of a 50g image.

Categories: sysadmin

Debian Jessie (or previous versions) postfix chroot additions

September 16, 2015 Leave a comment

Postfix runs chrooted by default on most distributions. Jessie is no exception.
There are a couple of crucial modifications that are important and not well documented.

1) If you are running sasl, then this is the correct way to configure the chroot sasl
connection. Test your install first using testsaslauth -u [user] -p [password]. If you
get no connect or some other error you need the following additions.

rm -r /var/run/saslauthd/
mkdir -p /var/spool/postfix/var/run/saslauthd
ln -s /var/spool/postfix/var/run/saslauthd /var/run
chgrp sasl /var/spool/postfix/var/run/saslauthd
adduser postfix sasl
service postfix restart
service saslauthd restart

Then retest with testsaslauth you should get OK “Success.”

2) The cache files of postfix are also chrooted into the /var/spool/var/lib/postfix(chroot)
directory. If you do not see the cache files listed below in this directory, then
complete the following to correct the cache file locations.

The cache directory /var/lib/postfix contains:
master.lock, prng_exch, smtpd_scache.db, smtp_scache.db,and verify_cache.db.
To be safe copy these files and restore them to the new chrooted folder.
They will update after restarting postfix.

rm -r /var/lib/postfix
mkdir -p /var/spool/postfix/var/lib/postfix
ln -s /var/spool/postfix/var/lib/postfix /var/lib
chgrp postfix /var/spool/postfix/var/lib/postfix
chown -R postfix:postfix /var/spool/postfix/var/lib/
service postfix restart

You can test by running:
postmap -s btree:/var/lib/postfix/verify_cache
You should see no errors.

Categories: sysadmin

Debian Jessie kvm vm – intel_rapl not found error on boot

August 9, 2015 Leave a comment

Just blacklist this module. Add a .conf file to /etc/modprobe.d

intel.conf
blacklist intel_rapl

or any other .conf blacklist you already have as any .conf file is searched.

reboot

Categories: sysadmin

systemd display-manager.service error kvm vm, Debian Jessie os

August 9, 2015 Leave a comment

If you are receiving this error in dmesg upon boot:

Cannot add dependency job for unit display-manager.service, ignoring: Unit display-manager.service failed to load: No such file or directory.

Execute these commands via cli to fix.

1) systemctl get default (look at result)
2) If the result is graphical display, then continue with 3
3) systemctl set-default multi-user.targetsys
4) systemctl get default (recheck result) should be multi-user.target

reboot your vm and you should no longer see the error in dmesg.

Categories: sysadmin