├── Dockerfile ├── README.md ├── afp.conf ├── init └── 10_dbus.sh └── services ├── avahi └── run ├── dbus └── run └── netatalk └── run /Dockerfile: -------------------------------------------------------------------------------- 1 | # use 12.04 precise (https://github.com/docker/docker/issues/5899) 2 | FROM phusion/baseimage:0.9.9 3 | MAINTAINER Arve Seljebu arve.seljebu@gmail.com 4 | 5 | # no ssh 6 | RUN rm -rf /etc/service/sshd /etc/my_init.d/00_regen_ssh_host_keys.sh 7 | 8 | # environment 9 | ENV DEBIAN_FRONTEND noninteractive 10 | ENV HOME /root 11 | 12 | # use baseimage init system 13 | CMD ["/sbin/my_init"] 14 | 15 | # install netatalk 3 from ppa 16 | RUN \ 17 | echo "deb http://ppa.launchpad.net/ali-asad-lotia/netatalk-stable/ubuntu precise main" > /etc/apt/sources.list.d/netatalk3.list && \ 18 | apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AC857259 && \ 19 | apt-get update && \ 20 | apt-get install -y --no-install-recommends netatalk avahi-daemon 21 | 22 | # clean up 23 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 24 | 25 | # add user 26 | RUN useradd --home /backup -m timemachine 27 | RUN echo timemachine:timemachine | chpasswd 28 | 29 | # time machine volume 30 | VOLUME /backup 31 | 32 | # port 33 | EXPOSE 548 34 | 35 | # afp config 36 | ADD afp.conf /etc/netatalk/afp.conf 37 | 38 | # add init and services 39 | ADD init/ /etc/my_init.d/ 40 | ADD services/ /etc/service/ 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # arve0/timemachine 2 | Netatalk running in docker for time machine backups. 3 | 4 | ``` 5 | docker pull arve0/timemachine 6 | docker run -e "PASSWORD=asdf" -v /host/mnt/backup:/backup -p 548:548 --net=host -d arve0/timemachine 7 | ``` 8 | 9 | Connect with timemachine:asdf. If environment variable `PASSWORD` is not set, *timemachine* is the default password. 10 | 11 | # notes on bonjour/avahi/zeroconf 12 | [Network discovery](http://en.wikipedia.org/wiki/Bonjour_(software)) only works if afp daemon is on same network as client. Therefore `--net=host` is required if you would like the disk to show in Finder. If you don't need this, you can remove `--net=host` and connect in Finder with `cmd+k` -> `afp://hostname/` 13 | 14 | Note that `--net=host` doesn't work with ubuntu trusty 14.04: https://github.com/docker/docker/issues/5899 15 | 16 | # ideas from 17 | - https://bitbucket.org/lonix/plex/src 18 | - https://github.com/bySabi/dockerfiles/tree/master/nas 19 | - https://github.com/aequitas/timemachine 20 | -------------------------------------------------------------------------------- /afp.conf: -------------------------------------------------------------------------------- 1 | [Global] 2 | mimic model = TimeCapsule6,106 3 | log level = default:info 4 | log file = /var/log/afpd.log 5 | zeroconf = yes 6 | 7 | [TimeMachine] 8 | path = /backup 9 | valid users = timemachine 10 | time machine = yes 11 | -------------------------------------------------------------------------------- /init/10_dbus.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -e /var/run/dbus/pid ]; then rm -f /var/run/dbus/pid; fi 4 | mkdir -p /var/run/dbus 5 | chown messagebus:messagebus /var/run/dbus 6 | dbus-uuidgen --ensure 7 | sleep 1 8 | -------------------------------------------------------------------------------- /services/avahi/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | exec avahi-daemon --no-chroot 4 | -------------------------------------------------------------------------------- /services/dbus/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | exec dbus-daemon --system --nofork 4 | -------------------------------------------------------------------------------- /services/netatalk/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # set password if defined (docker run -e "PASSWORD=asdf") 4 | if [-z "PASSWORD"]; 5 | then 6 | echo Using default password: timemachine 7 | else 8 | echo Setting password from environment variable 9 | echo timemachine:$PASSWORD | chpasswd 10 | fi 11 | 12 | # wait for avahi-daemon 13 | sv start avahi || exit 1 14 | 15 | # run in foreground 16 | exec netatalk -d 17 | --------------------------------------------------------------------------------