You are not logged in.

#1 2010-04-18 20:30:33

demian
Member
From: Frankfurt, Germany
Registered: 2009-05-06
Posts: 709

[solved] backup function: works with bash but not with zsh

Hi everyone,

I've got this handy backup function which worked fine for me when i was using bash.
But since I've switched to zsh yesterday i noticed the script isn't working anymore.

  # root functions
  backup () { # backup files to /home/slave/.backup/backup-$DATE.tar.bz2
    DATE=$(date +%Y-%m-%d-%H%M%S)
    BACKUP_DIR="/home/slave/.backup"
    SOURCE="/boot/grub/menu.lst /etc/conf.d /etc/exports /etc/fuse.conf /etc/clamav/clamd.conf /etc/lighttpd/lighttpd.conf /etc/php/php.ini /etc/rc.d/rtorrent /etc/sudoers /etc/inittab /etc/acpi/events/power /etc/mkinit* /etc/modprobe.d/modprobe.conf /etc/ssh/sshd_config /etc/rc.conf /etc/rc.local /etc/rc.sys* /etc/issu* /etc/hosts* /etc/resolv.conf /etc/pacman.conf /etc/pacman.d/mirrorlist /etc/fstab /etc/mpd.conf /etc/samba/smb.conf /etc/hal/fdi/policy/*.fdi /etc/laptop-mode /etc/xdg/user-dirs.defaults /home/slave/.rtorrent.rc /home/slave/.conkyrc /home/slave/.xinitrc /proc/config.gz /root /srv/http /usr/share/vlc/http/.hosts /usr/share/pcmanfm/mount.rules /var/lib/mpd/playlists"
    tar -cjpf $BACKUP_DIR/backup-$DATE.tar.bz2 $SOURCE
  }

The error message says that tar can't find ANY of the above files. I've tried it with relative paths, with or without having tar remove the leading '/', also ignore-error parameters and i removed wildcards from the SOURCE paths.
I'm out of ideas and honestly i'm not that familiar with zsh yet. Hopefully one of you is and can help me out.

Thanks,
demian

P.S.: If it helps, here is the .zshrc: http://paste.pocoo.org/show/203398/

Last edited by demian (2010-04-22 15:33:51)


no place like /home
github

Offline

#2 2010-04-19 22:10:02

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,774

Re: [solved] backup function: works with bash but not with zsh

Did you uninstall Bash?  If not you could take the easy way out and make the first line of the script read as follows:

#!/bin/bash

Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2010-04-19 22:31:57

demian
Member
From: Frankfurt, Germany
Registered: 2009-05-06
Posts: 709

Re: [solved] backup function: works with bash but not with zsh

Hi,

I've only used it as function up to now. I'll try it as script tomorrow.
I'm still curious if it's possible to get the function to run with zsh.


Update: I've solved the issue. It wasn't working because ZSH apparently treats arrays differently. Instead of x="y1 y2 y3 y4" you have to use x=(y1 y2 y3 y4).

Greets,
demian

Last edited by demian (2010-04-22 15:36:26)


no place like /home
github

Offline

Board footer

Powered by FluxBB