Skip to content

Instantly share code, notes, and snippets.

@faizal2007
faizal2007 / zimbra-backup-emails.sh
Created August 9, 2017 03:58 — forked from filippo/zimbra-backup-emails.sh
How to backup and restore emails of a specific account on zimbra
# The command below creates a tgz file with all emails for [email protected] in .eml format:
# execute as root
/opt/zimbra/bin/zmmailbox -z -m [email protected] getRestURL "//?fmt=tgz" > /tmp/account.tgz
# You can do the same via a REST URL:
wget http://ZIMBRA.SERVER/home/[email protected]/?fmt=tgz
# to restore email:
/opt/zimbra/bin/zmmailbox -z -m [email protected] postRestURL "//?fmt=tgz&resolve=reset" /tmp/account.tgz
@faizal2007
faizal2007 / snapshot_restore
Last active March 1, 2020 07:31
Sample related script to manage xen with xen-tools
## Need to run manual paste command
### Create snapshot
lvcreate -L50G -s -n centos-disk-snapshot /dev/sanbox-vg/centos-disk-fresh
### Restore snapshot
lvconvert --merge /dev/sanbox-vg/centos-disk-snapshot
lvchange -an /dev/sanbox-vg/centos-disk-fresh
lvchange -ay /dev/sanbox-vg/centos-disk-fresh
@faizal2007
faizal2007 / l2tp-elementary
Created March 12, 2020 15:31
Create l2tp elementary
## Install related library
sudo apt install git intltool libtool network-manager-dev libnm-util-dev libnm-glib-dev libnm-glib-vpn-dev libnm-gtk-dev libnm-dev libnma-dev ppp-dev libdbus-glib-1-dev libsecret-1-dev libgtk-3-dev libglib2.0-dev xl2tpd strongswan libnss3-dev libssl-dev
git clone https://github.com/nm-l2tp/network-manager-l2tp.git
cd network-manager-l2tp
autoreconf -fi
intltoolize
./configure \
--disable-static --prefix=/usr \
@faizal2007
faizal2007 / getuserowncloud.sh
Created March 21, 2020 10:15
bash iterate jason data from owncloud occ
sudo -u www-data /usr/bin/php -f /var/www/html/owncloud/occ user:list --output=json --attributes=uid | jq 'del(.freakie)' | jq -r 'keys | .[]'
@faizal2007
faizal2007 / redmine_notes
Last active March 26, 2020 11:29
redmine installation notes
#Install plugin
bundle config set without 'development test'
bundle config set path 'vendor/bundle'
bundle install
bundle exec rake redmine:plugins NAME=redmine_checklists RAILS_ENV=production
touch tmp/restart.txt
@faizal2007
faizal2007 / example.com.conf
Last active June 26, 2021 11:45
Bind9 basic config
; create file in /var/named/example.com
; example.com
$TTL 3600
example.com. IN SOA ns1.example.com. [email protected]. (
2021062601 ; Serial
3H ; refresh after 3 hours
1H ; retry after 1 hour
1W ; expire after 1 week
1D) ; minimum TTL of 1 day
@faizal2007
faizal2007 / iptables-nat-multiport.sh
Last active April 12, 2021 08:37
Port forwarding for incoming port using iptables
#!/bin/bash
# The MIT License (MIT)
#
# Copyright (c) 2016 Faizal Sadri
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@faizal2007
faizal2007 / postgres_queries_and_commands.sql
Created April 10, 2021 04:47 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@faizal2007
faizal2007 / lv-snapshot.sh
Created April 24, 2021 16:44
Archive snapshot and delete old copy
#!/bin/bash
VG_GROUP=geekha
LV_NAME=www1-disk
DATE="$(date +%Y_%m_%d-%H%M)"
LV_TAG=snapshot
SIZE=20G
# retention copy
COPY=3
lvcreate -L$SIZE -s -n $LV_NAME-$LV_TAG-$DATE /dev/$VG_GROUP/$LV_NAME
@faizal2007
faizal2007 / check_port.sh
Created April 26, 2021 23:30
Check open open
#!/bin/bash
CMD="$(dirname $0)/$(basename $0)"
if [ $# -ne 2 ]; then
echo "${CMD} <ip> <port>"
else
echo > /dev/tcp/$1/$2 && echo "open"
fi
#echo > /dev/tcp/192.168.1.41/9100 && echo "open"