Tag Archives: backup

Barman

# install barman
apt-get install barman

# generate ssh keys for user barman
sudo -u barman -i
ssh-keygen
cd ~/.ssh/
cp id_rsa.pub authorized_keys
# cat id_rsa.pub and copy it
exit

# generate ssh keys for user postgres
sudo -u postgres -i
ssh-keygen
cd ~/.ssh/
cp id_rsa.pub authorized_keys
# put barman's id_rsa.pub into postgres's authorized_keys
# cat postgres'sid_rsa.pub and copy it
exit

sudo -u barman -i
# put id_rsa.pub postgres's id_rsa.pub into barman's authorized_keys
exit

add config of your postgresql server into /etc/barman.conf:

1
2
3
4
[srv1]
description = "srv1 pgsql"
ssh_command = ssh postgres@127.0.0.1
conninfo = host=127.0.0.1 user=postgres

where srv1 — name of server

barman check
barman status srv1
barman backup srv1
barman cron
man barman

backup /etc/ with etckeeper

etckeeper allows the contents of

1
2
/etc be easily stored in Version Control System (VCS) repository.
It hooks into apt to automatically commit changes to <code>/etc

when packages are installed or upgraded.
Placing

1
/etc

under version control is considered an industry best practice,
and the goal of etckeeper

1
 is to make this process as painless as possible.

1
sudo apt-get install etckeeper bzr

edit /etc/etckeeper/etckeeper.conf
# The VCS to use.
#VCS="hg"
#VCS="git"
VCS="bzr"
#VCS="darcs"

cd /etc/
bzr init
bzr nick «$(hostname) /etc repository»
etckeeper commit «first adding of /etc»

Now you have local repository in /etc/.bzr
and can revert your configs if you have made something wrong like rm -rf /etc/apache2 (O_o! UPS!!!!)

How to work with bzr:
look at logs:

1
bzr log --short /etc


look at logs with changed files:

1
<strong>bzr log -v --short /etc</strong>

look at last 20 logs:

1
bzr log --line /etc | head -n 20


look at changes from last commit:

1
bzr status /etc


look at chenges betweet last commit and current state:

1
bzr diff /etc


look at diff between two version of commits:

1
bzr diff -r 8..7 /etc


look at logs in verbose mode:

1
bzr log -p /etc/squid3 | less


revert changes:

1
2
3
bzr revert -r5 /etc/squid3/somefile
bzr revert -r5 /etc/squid3
bzr revert /etc/squid3

os x: time machine, backup to debian squeeze

add to /etc/apt/sources.list
# stable repo
deb http://cdn.debian.net/debian squeeze main
# new testing repo
deb http://cdn.debian.net/debian wheezy main

apt-get update
apt-get install netatalk

edit /etc/netatalk/afpd.conf 
 - -tcp -noddp -uamlist uams_dhx.so,uams_dhx2_passwd.so -nosavepassword -mimicmodel Xserve

edit /etc/netatalk/AppleVolumes.default
/backup/osx «Backup folder» options:usedots,upriv,tm allow:alter,admin

edit /etc/avahi/services/afpd.service 
<service-group>
<name replace-wildcards=”yes”>%h</name>
<service>
<type>_afpovertcp._tcp</type>
<port>548</port>
</service>
<service>
<type>_device-info._tcp</type>
<port>0</port>
<txt-record>model=Xserve</txt-record>
</service>
</service-group>

/etc/init.d/netatalk restart
/etc/init.d/avahi-daemon restart

in the mac os x console:

defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1

backup dd-wrt

Settings of such equipment is typically stored in nonvolatile memory. The devices can be found in the proc / mtd

root @ router: ~ # cat / proc / mtd
dev: size erasesize name
# Boot
mtd0: 00040000 00010000 "cfe
"
# Kernel
mtd1: 003b0000 00010000 "linux
"
# Root filesystem
mtd2: 001db400 00010000 "rootfs
"
# Parameters
mtd3: 00010000 00002000 "nvram
"
# Free partition (where I keep extra initialization scripts)
mtd4: 000f0000 00010000 «ddwrt»

Now, where do a full dump of interest to us section, and save somewhere on your computer.

# Do a dump
root @ router: ~ # dd if = / dev/mtdblock/3 of = / tmp / config.dd
128 0 records in
128 0 records out
root @ router: ~ #

# Save to your computer
yurial @ note: ~ $ scp root@192.168.0.1: / tmp / config.dd config.dd

To restore the settings to produce the inverse operation, and reboot.

# Copy the settings from your PC to your device
yurial @ note: ~ $ scp config.dd root@192.168.0.1: / tmp / config.dd

# Copy the settings from the dump
root @ router: ~ # dd if = / tmp / config.dd of = / dev/mtdblock/3
# Reboot
# Ps before rebooting unplug usb-connected devices
root @ router: ~ # reboot-f

In general, this way you can make a backup, not only for firmware dd-wrt, and not only on dir-320. Such a method suitable, for example, to backup iphone, or geeksphone.

PS: on my dir-320 under its own firmware before restarting I would do a sync, to make sure that all data were recorded. However, under dd-wrt I, this led to the crash.

dd-wrt backup

Settings of such equipment is typically stored in nonvolatile memory. The devices can be found in the /proc/mtd

root@router:~# cat /proc/mtd
dev:    size   erasesize  name
#loader
mtd0: 00040000 00010000 "cfe"
#kernel
mtd1: 003b0000 00010000 "linux"
#root file system
mtd2: 001db400 00010000 "rootfs"
#settings
mtd3: 00010000 00002000 "nvram"
#free partition (I keep it extra initialization scripts)
mtd4: 000f0000 00010000 "ddwrt"

Now, where do a full dump of interest to us section, and save somewhere on your computer.

#dump
root@router:~# dd if=/dev/mtdblock/3 of=/tmp/config.dd
128+0 records in
128+0 records out
#store on your computer
yurial@note:~$ scp root@192.168.0.1:/tmp/config.dd config.dd

To restore the settings to produce the inverse operation, and reboot.

#copy the settings from your PC to your device
yurial@note:~$ scp config.dd root@192.168.0.1:/tmp/config.dd
#copy the settings from the dump
root@router:~# dd if=/tmp/config.dd of=/dev/mtdblock/3
#reboot
#ps  before rebooting, disconnect usb-connected devices
root@router:~# reboot -f

In general, this way you can make a backup, not only for firmware dd-wrt, and not only on dir-320. Such a method suitable, for example, to backup iphone, or geeksphone.

PS: on my dir-320, under my own firmware before restarting I would do a sync, to make sure that all data were recorded. However, under dd-wrt I, this led to the crash.

backup mp-124

Save the config with Audiocodes MediaPack 124 on the list of ip:

#!/bin/sh
 day=`/bin/date "+%Y%m%d"`
 home_dir="/home/alter/backups/mp124/$day"
 /bin/mkdir $home_dir;
 /bin/cat /home/alter/mp124ip.txt | /usr/bin/awk '{system("/usr/local/bin/curl --digest --url http://Admin:Admin@"$1"/FS/BOARD.ini>'$home_dir'/"$1".ini")}'

Create a text file mp124ip.txt and fill it with the principle of one-row 1 IP Address:

10.166.10.4
192.168.1.34

and etc...