rasti.hil@hilandco.com +41 79 367-9677

Search This Blog

Daily backup under Ubuntu

Step 1) create a file:
sudo mcedit /root/daily_backup.sh

Write the following lines to file (try to put it without line break) :
rsync -a --delete --log-file=/data/backup/crontab_log/$(date +%Y%m%d)_rsync.log --exclude "/media" --exclude "/mnt" --exclude "/home" --exclude "/data" --exclude "/proc" --exclude "/lost+found" --exclude "/dev" --exclude "/sys" --exclude "/tmp" --exclude "/var/cache/apt/" --exclude "/cdrom" / /data/backup/crontab_ubuntu_backup

What does this command?
-a: means that copy file in archive mode, once the file is copied next time only the changes will be copied;
--delete: delete files from destination if they are deleted from source;
--log-file: where to put log file;
--exclude: exclude files matching the pattern;
/: source, in my case it is the root (/);
/data/backup/crontab_ubuntu_backup: destination;

Step 2) make file executable:
sudo chmod +x /root/daily_backup.sh

Step 3) create a cron job:
sudo crontab -e

Under the line "# m h dom mon dow command" start a new line and write:
1 2 * * * /root/daily_backup.sh

Once again what does it mean?
- 1: number of minutes;
- 2: number of hours (0-24);
- *: day of month;
- *: month;
- *: day of week;
- /root/daily_backup.sh: command to execute;
so I have created a job that executes every day at 02:01 h.

Take a look on the following sites for detailed description for the rsync and crontab command.

janos ujvari @October 21, 2008.

Extending swap space

Recently I have run into a problem when I want to install some program on my Ubuntu machine.
The problem was that the program figured out that the machine has not have enough swap space so i had to extend it:

Step 1.: create a swap file;
sudo dd if=/dev/zero of=/extraswap.img bs=1M count=500
this command would create an 500MB file.

Step 2.: alter the create file
sudo touch /extraswap.img

Step 3.: "turn it on" as a swap file
sudo swapon /extraswap.img

Step 4.: add entries to /etc/fstab file
/extraswap.img none swap defaults 0 0

janos ujvari @ 14th, October 2008

Mount remote folders with sshfs

Trough my work I had have a need for remote folders/files; so when it is possible I am using sshfs to mount remote things.

Step 1:
create a mount folder:
sudo mkdir /mnt/remote

Step 2:
mount remote folder:
sudo sshfs someuser@remote_machine:/home/someuser/somfolder /mnt/remote

Step 3:
get to work!

Step 4:
unmounting remote folder:
sudo umount /mnt/remote
or you can use the following, but I prefer the first one:
sudo fusermount -u /mnt/remote

Note: if you want to enable access to ather users use the allow_other option:
sudo sshfs someuser@remote_machine:/home/someuser/somfolder /mnt/remote -o allow_other

janos ujvari @October 11, 2008