- Make new directory and change into it
~ $ mkdir my-files
~ $ cd my-files
- Add a new file to the directory
~/my-files $ echo "It was a dark and stormy night..." > memoir.txt
- Create dat from the directory and share it
~/my-files $ dat share
dat v13.11.4
Created new dat in /Users/james/my-files/.dat
dat://65bf19952067c4bb55769d8a9053835d840dddaee062c8c53a4c9b68b5d8adee
Sharing dat: 1 files (34 B)
0 connections | Download 0 B/s Upload 0 B/s
Watching for file updates
- This is now watching the directory, so adding another file in will cause the dat to be updated and rebroadcast
- Create directory to store the dat archive
~ $ mkdir my-files-clone
~ $ cd my-files-clone
- Create "feeds" file listing out the dat links the archiver should automatically update
~/my-files-clone $ echo "dat://65bf19952067c4bb55769d8a9053835d840dddaee062c8c53a4c9b68b5d8adee" > feeds
- Run
hypercored
~/my-files-clone $ hypercored
Watching /home/ubuntu/my-files-clone/feeds for a list of active feeds
Swarm listening on port 3282
Archiver key is 3bee06faee91d7b8356cb893729aa66b1b43fc87bd0231767c5c28164dd540c8
Adding 65bf19952067c4bb55769d8a9053835d840dddaee062c8c53a4c9b68b5d8adee
- This synchronises the dat to the server, and will create the following directory structure:
ubuntu@ip-172-31-26-100:~/my-files-clone $ ll
total 16
drwxrwxr-x 3 ubuntu ubuntu 4096 Sep 20 08:04 ./
drwxr-xr-x 18 ubuntu ubuntu 4096 Sep 20 08:04 ../
drwxrwxr-x 4 ubuntu ubuntu 4096 Sep 20 08:04 archiver/
-rw-rw-r-- 1 ubuntu ubuntu 71 Sep 20 08:04 feeds
The server is now continually updating it's own copy of the files discovered in the dat, which means if the files on your local computer are lost, then there is still a copy available.
Test this by going to the datbase site using the dat link that you got at the beginning in step 3:
This page should load the files that are in your directory, and if both local and remote are running then it should display "2 sources available".
Now, if you stop the dat share on the local computer, and even delete the local directory (rm -rf my-files
), then the datbase site should display "1 source available", because the server is still running and serving a clone of the original directory.
Note: before deleting the local directory, try adding another file to it and refreshing the datbase site to show that the new file was broadcast.