Snippets

mysqldump – export MySQL DB from Windows using WSL

mysqldump -h localhost --port=3306 --protocol=TCP -uroot -p test_countryapi > dump.sql

#bzip2
mysqldump -h localhost --port=3306 --protocol=TCP -uroot -p test_countryapi | bzip2 > dump.sql.bz2
#with datetime
mysqldump -h localhost --port=3306 --protocol=TCP -uroot -p test_countryapi | bzip2 > dump-$(date '+%Y%m%d-%H%M%S').sql.bz2

#gzip
mysqldump -h localhost --port=3306 --protocol=TCP -uroot -p test_countryapi | gzip > dump.sql.gz

Ubuntu – Create a new User with custom Home Directory and add to “www-data” group

# copy from existing skel
cp -r /etc/skel /etc/skel-for-web-users
cd /etc/skel-for-web-users
sudo mkdir configs logs web web/public_html
cd logs
touch error.log
touch access.log

# verify contents with
tree /etc/skel-for-web-users
# should output
/etc/skel-for-web-users
├── configs
├── logs
│   ├── access.log
│   └── error.log
└── web
    └── public_html

4 directories, 2 files

Cmder – Windows Setup

Using Git Bash Settings -> Integration: Command: `/single /icon D:\_cmder\icons\cmder_red.ico -run {Git Bash}` Icon File: `”D:\_cmder\icons\cmder_red.ico”`

Rsync – Basic usage

rsync -avz -e "ssh -p 6395" user@host.com:/home/user/public_html/wp-content/uploads/* public_html/wp-content/uploads